[PATCH 2009-01-22] fix handling of final ECHILD (last traced process exited)

Denys Vlasenko dvlasenk at redhat.com
Mon Feb 23 13:51:42 UTC 2009


diff -x CVS -urpN 2009-01-21/ChangeLog 2009-01-22/ChangeLog
--- 2009-01-21/ChangeLog	2009-01-17 02:52:54.000000000 +0100
+++ 2009-01-22/ChangeLog	2009-01-21 20:05:43.000000000 +0100
@@ -1,3 +1,9 @@
+2009-01-21  Denys Vlasenko  <dvlasenk at redhat.com>
+
+	* strace.c (collect_stopped_tcbs): Do not return NULL when ECHILD
+	is detected, return collected list instead. Fixes symptom when
+	the last "+++ killed by SIGxxx +++" is not printed.
+
 2009-01-17  Denys Vlasenko  <dvlasenk at redhat.com>
 
 	Two cleanups: tcb table expansion failure is not really a survivable
diff -x CVS -urpN 2009-01-21/strace.c 2009-01-22/strace.c
--- 2009-01-21/strace.c	2009-01-17 02:52:54.000000000 +0100
+++ 2009-01-22/strace.c	2009-01-21 20:05:43.000000000 +0100
@@ -27,7 +27,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- *	$Id: strace.c,v 1.102 2009/01/17 01:52:54 vda_linux Exp $
+ *	$Id: strace.c,v 1.103 2009/01/21 19:05:43 vda_linux Exp $
  */
 
 #include "defs.h"
@@ -2309,10 +2309,9 @@ collect_stopped_tcbs(void)
 			break;
 		}
 		if (pid == -1) {
-			switch (wait_errno) {
-			case EINTR:
+			if (wait_errno == EINTR)
 				continue;
-			case ECHILD:
+			if (wait_errno == ECHILD) {
 				/*
 				 * We would like to verify this case
 				 * but sometimes a race in Solbourne's
@@ -2320,17 +2319,16 @@ collect_stopped_tcbs(void)
 				 * ECHILD before sending us SIGCHILD.
 				 */
 #if 0
-				if (nprocs == 0)
-					return NULL;
-				fprintf(stderr, "strace: proc miscount\n");
-				exit(1);
+				if (nprocs != 0) {
+					fprintf(stderr, "strace: proc miscount\n");
+					exit(1);
+				}
 #endif
-				return NULL;
-			default:
-				errno = wait_errno;
-				perror("strace: wait");
-				exit(1);
+				break;
 			}
+			errno = wait_errno;
+			perror("strace: wait");
+			exit(1);
 		}
 		if (pid == popen_pid) {
 			if (WIFEXITED(status) || WIFSIGNALED(status))






More information about the Strace-devel mailing list