How can a parent find out if one of its children is still alive
Michael Meissner
meissner at osf.org
Thu Jun 7 09:11:14 AEST 1990
In article <13071 at ulysses.att.com> smb at ulysses.att.com (Steven
Bellovin) writes:
| Path: paperboy!think!snorkelwacker!usc!ucsd!ucbvax!ulysses!ulysses.att.com!smb
| From: smb at ulysses.att.com (Steven Bellovin)
| Newsgroups: comp.unix.wizards
| Date: 6 Jun 90 19:22:28 GMT
| References: <30408 at cup.portal.com> <6334 at ozdaltx.UUCP> <1046 at gargoyle.uchicago.edu>
| Sender: netnews at ulysses.att.com
| Distribution: na
| Lines: 15
|
| In article <1046 at gargoyle.uchicago.edu>, matt at group-w.uchicago.edu (Matt Crawford) writes:
| } ) DeadHead at 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.
Unless of course, the newly created pid is running one of your cron
jobs, a different job created by your job control shell, on a
different window owned by you, or somebody running nethack which is
setuid to your account. Kill only checks for the effective UID being
the same.
The above methods are ways there can be a process with the same PID as
a dearly departed child process, and have the same EUID as the parent
proces, but not be the process the parent wants to deal with. I'm
sure I've missed a few ways to create such processes.
--
Michael Meissner email: meissner at osf.org phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA
Catproof is an oxymoron, Childproof is nearly so
More information about the Comp.unix.wizards
mailing list