How can a parent find out if one of its children is still alive
Tom Lawrence
tcl at cs.brown.edu
Thu Jun 7 22:50:49 AEST 1990
In article <MEISSNER.90Jun6191114 at curley.osf.org> meissner at osf.org (Michael Meissner) writes:
>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.
I'd like to point out that pid numbers aren't recycled for a while. It
may take quite a long time on a machine which is relatively unused.
I think the best way to reliably check the status of a child process
is to catch the SIGCHLD signal, which is delivered when the status of
a child process changes. (this signal is normally ignored). The
handler routine can either explicitely do whatever you want to do when
the child dies, or set some global flag which the main thread will
later check.
* Tom Lawrence A is for apathy *
* tcl at cs.brown.edu B is for boredom *
* C is for... oh the hell with it *
More information about the Comp.unix.wizards
mailing list