Bug 53191 - strace fails to ensure that SIG_CHLD isn't ignored.
Summary: strace fails to ensure that SIG_CHLD isn't ignored.
Alias: None
Product: Red Hat Public Beta
Classification: Retired
Component: strace
Version: skipjack-beta2
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Roland McGrath
QA Contact: Brian Brock
Depends On:
TreeView+ depends on / blocked
Reported: 2001-09-04 23:53 UTC by David Woodhouse
Modified: 2007-04-18 16:36 UTC (History)
0 users

Clone Of:
Last Closed: 2003-01-10 23:02:32 UTC

Attachments (Terms of Use)

Description David Woodhouse 2001-09-04 23:53:13 UTC
If strace inherits an action of SIG_IGN for SIGCHLD, it'll fail to operate

cat > breakstrace.c <<EOF
#include <signal.h>
#include <unistd.h>

int main(void)
	execl("/bin/bash", "/bin/bash", NULL);
make breakstrace
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.

Comment 1 Roland McGrath 2002-08-21 02:47:03 UTC
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.

Comment 2 Roland McGrath 2002-12-17 09:24:25 UTC
Fixed upstream for next release.

Comment 3 Roland McGrath 2003-01-10 23:02:32 UTC
Version 4.4.91-1 should work fine.

Note You need to log in before you can comment on or make changes to this bug.