Re: Get parent process (Carbon question)
Re: Get parent process (Carbon question)
- Subject: Re: Get parent process (Carbon question)
- From: Hasan Diwan <email@hidden>
- Date: Fri, 6 Sep 2002 21:43:33 -0700
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
The name of the process is in argv[0]. The process id may be found
using the getpid() system call as follows:
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
int main (int argc, char **argv) {
pid_t p;
p = getpid();
fprintf(stderr, "%s: process id %d\n", argv[0], p);
return 0;
}
Hope it helps!
On Friday, September 6, 2002, at 03:22 PM, Ondra Cada wrote:
On Friday, September 6, 2002, at 11:16 , Renaud Boisjoly wrote:
I was looking for a way to get the process id and then figure out the
name of the process... but I nopw realise I do not knowhow to do
this, apart from executing a ps command and parsing it out
in my personal opinion launching&parsing
ps -cp <pid> -o command
is the simplest way to do that.
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
Hasan Diwan
OpenPGP KeyID: 0xBE42DCA6
Fingerprint: 1CB0 47E3 0A24 DAC1 DCCA 4225 F166 40C2 BE42 DCA6
http://www.cs.rpi.edu/~diwanh/gpg.key
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (Darwin)
iD8DBQE9eYP+8WZAwr5C3KYRAtI2AJoCnfAnv+46qE3xh/OgKnqONYAuEACfX6jd
jtejAYqTr7fN2IsBg4Cu6sY=
=dfaX
-----END PGP SIGNATURE-----
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.