Red Hat Bugzilla – Bug 53191
strace fails to ensure that SIG_CHLD isn't ignored.
Last modified: 2007-04-18 12:36:51 EDT
If strace inherits an action of SIG_IGN for SIGCHLD, it'll fail to operate
cat > breakstrace.c <<EOF
execl("/bin/bash", "/bin/bash", NULL);
strace ls -lR /
SuS says that an action of SIG_IGN for SIGCHLD means that the kernel can
automatically reap dead child processes. So when ignoring the SIGCHLD from
the traced (and still alive) process, the kernel goes ahead and calls wait4
on behalf of the parent and discards the information which strace requires.
This breaks strace and gdbserver, and may break anything else which uses
ptrace. gdb is safe because it installs its own SIGCHLD handler.
strace can work around this by setting the SIGCHLD action to SIG_DFL.
The analysis is correct. Changing strace would be trivial enough.
But it is worth noting that running any program that uses wait* (or system
or popen or whatever) is likely to be flummoxed by having SIGCHLD ignored.
It's arguably just broken to run a program that way.
That said, I would be happy to change strace.
Fixed upstream for next release.
Version 4.4.91-1 should work fine.