[PATCH] libc: fix signal handling in system()

Rich Felker dalias at aerifal.cx
Mon Jan 16 14:54:24 UTC 2012


On Mon, Jan 16, 2012 at 10:54:52AM +0100, Richard Braun wrote:
> When built without NPTL support (or for a sparc target), the system()
> function doesn't conform to its specification. Namely, it uses signal()
> to install/save/restore signal handlers, which may break applications
> using custom handlers installed with sigaction(). In addition, it resets
> the SIGCHLD handler to SIG_DFL instead of blocking the signal, which may
> result in "lost" signals if a custom handler was installed.
> 
> Fix system() by replacing uses of signal() with appropriate calls to
> sigaction() and sigprocmask().

This is the THIRD time I've told you that blocking SIGCHLD rather than
ignoring it is non-conformant, and I provided the relevant citation
(link and quoted):

    The system() function shall ignore the SIGINT and SIGQUIT signals,
    and shall block the SIGCHLD signal, while waiting for the command
    to terminate. If this might cause the application to miss a signal
    that would have killed it, then the application should examine the
    return value from system() and take whatever action is appropriate
    to the application if the command terminated due to receipt of a
    signal.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/system.html

Rich


More information about the uClibc mailing list