Path: utzoo!attcan!uunet!brunix!tcl From: tcl@cs.brown.edu (Tom Lawrence) Newsgroups: comp.unix.wizards Subject: Re: How can a parent find out if one of its children is still alive Message-ID: <42180@brunix.UUCP> Date: 7 Jun 90 12:50:49 GMT References: <30408@cup.portal.com> <6334@ozdaltx.UUCP> <1046@gargoyle.uchicago.edu> <13071@ulysses.att.com> Sender: news@brunix.UUCP Reply-To: tcl@cs.brown.edu (Tom Lawrence) Distribution: na Organization: Brown University Department of Computer Science Lines: 26 In article meissner@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@cs.brown.edu B is for boredom * * C is for... oh the hell with it *