[PATCH] make sure SIGCHLD is not ignored

Roland McGrath roland at redhat.com
Mon Dec 16 02:05:03 UTC 2002


We had a Red Hat Linux user who ran an strace that inherited ignoring
SIGCHLD.  This makes the system drop wait status of zombies and generally
confuse the pants off strace.  I've advised the users that having SIGCHLD
ignored when they run any random program is liable to cause them pain.  But
it seems harmless enough to include this change:

2002-12-15  Roland McGrath  <roland at redhat.com>

	* strace.c (main) [! USE_PROCFS]: Always reset SIGCHLD to SIG_DFL.

Index: strace.c
===================================================================
RCS file: /cvsroot/strace/strace/strace.c,v
retrieving revision 1.31
diff -u -b -p -r1.31 strace.c
--- strace.c	6 Nov 2002 13:17:21 -0000	1.31
+++ strace.c	16 Dec 2002 10:04:11 -0000
@@ -548,6 +548,14 @@ char *argv[];
 #ifdef USE_PROCFS
 	sa.sa_handler = reaper;
 	sigaction(SIGCHLD, &sa, NULL);
+#else
+	/* Make sure SIGCHLD has the default action so that waitpid
+	   definitely works without losing track of children.  The user
+	   should not have given us a bogus state to inherit, but he might
+	   have.  Arguably we should detect SIG_IGN here and pass it on
+	   to children, but probably noone really needs that.  */
+	sa.sa_handler = SIG_DFL;
+	sigaction(SIGCHLD, &sa, NULL);
 #endif /* USE_PROCFS */
 
 	if (trace() < 0)




More information about the Strace-devel mailing list