Bug 53191

Summary: strace fails to ensure that SIG_CHLD isn't ignored.
Product: [Retired] Red Hat Public Beta Reporter: David Woodhouse <dwmw2>
Component: straceAssignee: Roland McGrath <roland>
Status: CLOSED RAWHIDE QA Contact: Brian Brock <bbrock>
Severity: high Docs Contact:
Priority: medium    
Version: skipjack-beta2   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-01-10 23:02:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.