Can a parent process determine its child's status ?

Martin Weitzel martin at mwtech.UUCP
Sat Feb 24 11:30:44 AEST 1990


In article <22 at ctbilbo.UUCP> ray at ctbilbo.UUCP (Ray Ward) writes:
[many correct things about getting the status of a child process]
>
>If you have the luxury of time, the ps command can be issued to the
>shell with a system() call.  A la:  "system("ps -ef > uniquefile");

Please, don't use "system" but "popen" and avoid the temporary file.
(It seems to me, that "popen" is often overlooked in the manuals,
because when learning C and UNIX, programmers do not see why it's
useful, and later they do not look again).

>This file can be read and searched for the pid and the status information
>parsed.  Why this isn't simply returned to the calling process in a 
>process status structure I don't know.  

Maybe in earlier days (when the source was available) UNIX programmers
could "steel" the algorithms from the "ps" command and incorporate
then directly into their code. Of course, this would only work for
programs with access to /dev/mem (and public access to /dev/mem would
be disastreous for system security). Really, a system call seems to
be missing here ...
-- 
Martin Weitzel, email: martin at mwtech.UUCP, voice: 49-(0)6151-6 56 83



More information about the Comp.unix.questions mailing list