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

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2003-01-10 23:02:32 UTC
Embargoed:


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
correctly.

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

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