[PATCH] libc: make system() block SIGCHLD

Richard Braun rbraun at sceen.net
Mon Jan 16 09:00:08 UTC 2012


On Sun, Jan 15, 2012 at 06:51:15PM -0500, Mike Frysinger wrote:
> On Sunday 15 January 2012 14:36:55 Richard Braun wrote:
> > On Sun, Jan 15, 2012 at 10:04:58AM -0500, Rich Felker wrote:
> > > Your report is wrong. system is REQUIRED by POSIX to change the signal
> > > disposition for SIGCHLD, not just to block the signal. It should
> > > change it to SIG_IGN, not SIG_DFL, but for practical purposes these
> > > are the same or similar.
> > 
> > I didn't notice that anywhere. Could you indicate where this behaviour
> > is specified exactly ?
> 
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/system.html
> 	The system() function shall ignore the SIGINT and SIGQUIT signals, and
> 	shall block the SIGCHLD signal, while waiting for the command to
> 	terminate

That part doesn't state "system is REQUIRED by POSIX to change the
signal disposition for SIGCHLD, not just to block the signal", on the
contrary, which is why I'm asking.

> > I agree the use of signal() immediately disturbed me, but I didn't read
> > its implementation. Maybe it does the job. In any case, we could use the
> > occasion to fix that as well and replace signal() with sigaction() in
> > the same patch.
> 
> Rich is referring to the extended aspects of signal handling that sigaction() 
> enables over signal() such as sa_sigaction and sa_flags.  signal() will 
> save/restore the handler just fine, but otherwise this function does subtly 
> break a few things ...

Sure, but I was implying the implementation of signal() might have used
some trick to correctly handle such cases, which is highly unlikely.

-- 
Richard Braun


More information about the uClibc mailing list