Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!ulysses!ulysses.att.com!smb From: smb@ulysses.att.com (Steven Bellovin) Newsgroups: comp.unix.wizards Subject: Re: How can a parent find out if one of its children is still alive Message-ID: <13071@ulysses.att.com> Date: 6 Jun 90 19:22:28 GMT References: <30408@cup.portal.com> <6334@ozdaltx.UUCP> <1046@gargoyle.uchicago.edu> Sender: netnews@ulysses.att.com Distribution: na Lines: 15 In article <1046@gargoyle.uchicago.edu>, matt@group-w.uchicago.edu (Matt Crawford) writes: } ) DeadHead@cup.portal.com (Bruce M Ong) writes: } ) > How can a parent find out if one of its children is still alive } ) > or not without } } Tom Armistead, wizard-wannabe, answers: } ) i.e.: if( kill( child_pid, 0 ) == -1 ) } ) puts( "The child is dead" ); } } overlooking the possibility that the child exited many minutes ago and } the pid is now being used by some unrelated process. You can look at errno to determine if the kill() failed because of a uid mismatch. That will yield a lot of info if root isn't doing the checking.