This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/10638] New: system(3) does not catch its own SIGCHLD
- From: "phdm at macqel dot be" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 14 Sep 2009 13:10:20 -0000
- Subject: [Bug libc/10638] New: system(3) does not catch its own SIGCHLD
- Reply-to: sourceware-bugzilla at sourceware dot org
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
--
Summary: system(3) does not catch its own SIGCHLD
Product: glibc
Version: 2.9
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: phdm at macqel dot be
CC: glibc-bugs at sources dot redhat dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=10638
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.