Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!usc!snorkelwacker!paperboy!meissner From: meissner@osf.org (Michael Meissner) Newsgroups: comp.unix.questions Subject: Re: Can process do an asynchronous wait? Message-ID: Date: 31 May 90 18:32:41 GMT References: <30343@cup.portal.com> Sender: news@OSF.ORG Organization: Open Software Foundation Lines: 29 In-reply-to: tms@cup.portal.com's message of 31 May 90 01:46:32 GMT In article <30343@cup.portal.com> tms@cup.portal.com (Alexis TMS Tatarsky) writes: | If a process forks and execs several child processes, is there any | way for the parent to detect when the child processes have exited | or died without having to wait(2) on them. I wrote a program where | the parent caught SIGCLD but I don't know which child it is which | died. If you are using select for other things, another approach than setting up a signal handler or waitpid with WNOHANG might be to open a pipe in the parent when doing a fork on each child, and pass the write end to the child (closing the read end in the child), and keeping the read end open in the parent (closing the write end in the parent). When the read file descriptor is available for I/O (assuming the child does write to the pipe or close the pipe file descriptor), it means that there are no more writers on the pipe, and that the child died. Of course the above assume that you have BSD system calls. On System V, you can either set up a signal handler (note System V, the semantics of the child death signal are different from BSD), or do the pipe trick and turn on async mode on the pipe (I don't remember the ioctl or fcntrl for this in the System V world off hand). -- Michael Meissner email: meissner@osf.org phone: 617-621-8861 Open Software Foundation, 11 Cambridge Center, Cambridge, MA Catproof is an oxymoron, Childproof is nearly so