[OT] poll() vs. AIO (was: [PATCH] ash: clear NONBLOCK flag from stdin when in foreground)

Rich Felker dalias at aerifal.cx
Mon Aug 22 12:18:07 UTC 2011


On Mon, Aug 22, 2011 at 08:33:42AM +0200, Laurent Bercot wrote:
> > This requires a global list/global state that is inherently
> > incompatible with library use, and just fundamentally bad programming.
> 
>  Only main-created subprocesses should be listed. Libraries should not
> even store the pid of their created processes anywhere, except to send
> them signals.

It's unsafe to ever send a signal unless you can ensure that you have
not waited on the process. Otherwise the pid may have been reused for
a new process. If you use the pipe method of determining if a child
has terminated, rather than waitpid, and if the SIGCHLD handler reaps
all children, then there is an inherent race condition whereby it is
NEVER safe to send signals, period.

Rich


More information about the busybox mailing list