UNIX process id trace
Tony Rems
rembo at unisoft.UUCP
Sat Oct 13 11:09:39 AEST 1990
In article <2738 at dataio.Data-IO.COM> peterson at Data-IO.COM (Joe Peterson) writes:
>I have a simple question:
>
>Is there a way to get the parent process id of any arbitrary
>process id? I know of getpid() and getppid(), but those only
>operate on the current process.
>
>I want to build a pid trace for the current process such as
>
> long pidtrace[REALLYBIG];
> long pid;
> int i;
>
> i=0;
> pid = getpid();
>
> while(pid != BOOTPROCESS)
> {
> pidtrace[i] = pid;
>
> ++i;
> pid = parentpid(pid);
> }
>
>where parentpid() is the magic function that I can't find.
>
>Any ideas?
>
>Joe Peterson
>peterson at Data-IO.COM
You could cheat and do a popen of "ps". Kernighan & Pike do it
in their zap program in "The UNIX Programming Environment".
-Tony
More information about the Comp.unix.questions
mailing list