* Shachar Shemesh <[EMAIL PROTECTED]> [070216 12:10]: > Baruch Even wrote: > > If it is a process parent/child pair then you could listen on the signal > > SIGCHLD and when the child exits your process will be notified by the > > kernel. > Well, no. > > The most obvious programs that will be run through privbind are daemons. > Those tend (I say "tend", but it's in the specs) to fork and exit parent > as a first thing. Privbind will not be the parent of the actual process > doing the binds.
That's why there is an "If it is a process parent/child pair..." leading there. I didn't bother looking at the specific use case. > > You'll need to wait() on the child process in the signal handler > > to reap the zombie child process. > > > Well, the idea is that a "recv" will terminate with no data and with > errno set to "EINTR" if a signal, such as SIGCHLD, arrives. This means > you can just call "recv", and if it fails, check the return code, and if > it's "EINTR" check whether the child has exited. You assume that the signal was received in the recv() call, you'll have a race condition where a child might die just before you go into recv() and the child is never reaped. The chance might be small to miniscule but it's still there. Baruch ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
