Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!unido!mikros!mwtech!martin From: martin@mwtech.UUCP (Martin Weitzel) Newsgroups: comp.unix.questions Subject: Re: Can a parent process determine its child's status ? Message-ID: <666@mwtech.UUCP> Date: 24 Feb 90 00:30:44 GMT References: <5090.25e135aa@mva.cs.liv.ac.uk> <22@ctbilbo.UUCP> Reply-To: martin@mwtech.UUCP (Martin Weitzel) Organization: MIKROS Systemware, Darmstadt/W-Germany Lines: 23 In article <22@ctbilbo.UUCP> ray@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@mwtech.UUCP, voice: 49-(0)6151-6 56 83