Bug 10638 - system(3) does not catch its own SIGCHLD
Summary: system(3) does not catch its own SIGCHLD
Status: RESOLVED INVALID
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.9
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-14 13:10 IST by Philippe De Muyter
Modified: 2014-07-01 06:51 IST (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe De Muyter 2009-09-14 13:10:19 IST
I have a program catching SIGCHLD itself, in order to e.g. restart failed
children processes.  This program also calls system(3) for children run once.
When system should return, I get a SIGCHLD instead, and my process gets blocked
endlessly in the wait call in my SIGCHLD handler, because the particular child
run by system does not exist anymore and has already been wait()ed for, I
assume, and my process has other children running.

This was not so on AIX and unix sysv systems, and the manpage of system says
nothing about such a behaviour

Here is a testcase :

#include <signal.h>
#include <stdio.h>

void sigcld(int signo)
        {
        int stat;

        printf("sigcld\n");
        wait(&stat);
        }

main(int argc, char **argv)
        {
        int child;

        if ((child = fork()) == 0)
                pause();
        if (!argv[1])
                signal(SIGCHLD, sigcld);
        system("date");
        kill(child, SIGTERM);
        }

If you run it as:
         ./a.out nosignalhandler
a.out terminates and kills the forked child
If you run it as:
         ./a.out
a.out gets blocked in the wait() call in the SIGCHLD handler
Comment 1 Philippe De Muyter 2009-09-15 11:35:49 IST
Sorry for wrong analysis.  On sysv and AIX, one also get a SIGCHLD at the end of
system(3), but on sysv the wait call in the sigcld handler returns, so that the
program does not block.  On AIX, the small example behaves as on linux, but my
real application does not block, while my application blocks on linux.  I don't
know at the moment what makes the difference between AIX and linux behaviours in
my application.
Comment 2 Petr Baudis 2009-09-18 13:53:54 IST
Ok, in that case please reopen when you find the reason if you think it really
is glibc bug.