[patch] Multithreaded process left Stopped (T) on CTRL-C of strace

Jan Kratochvil jan.kratochvil at redhat.com
Mon May 28 15:42:42 UTC 2007


Just a forgotten `Fixes RH#' ChangeLog entry.
-------------- next part --------------
2007-05-24  Jan Kratochvil  <jan.kratochvil at redhat.com>
	    Roland McGrath  <roland at redhat.com>

	* strace.c (detach): New prototype.
	[LINUX] (detach): Extended function comment.
	Call droptcb() instead of the wrong parametrized detach() call.
	(handle_group_exit): Call droptcb() instead of the wrong parametrized
	detach() call and instead of the inappropriate detach() call 
	Fixes RH#240961.

diff -u -rup strace-4.5.15-orig/strace.c strace-4.5.15-detach-zombie/strace.c
--- strace-4.5.15-orig/strace.c	2006-12-13 22:55:39.000000000 +0100
+++ strace-4.5.15-detach-zombie/strace.c	2007-05-24 18:11:05.000000000 +0200
@@ -83,6 +83,7 @@ unsigned int nprocs, tcbtabsize;
 char *progname;
 extern char **environ;
 
+static int detach P((struct tcb *tcp, int sig));
 static int trace P((void));
 static void cleanup P((void));
 static void interrupt P((int sig));
@@ -1282,7 +1283,10 @@ struct tcb *tcp;
 
 #endif /* !USE_PROCFS */
 
-/* detach traced process; continue with sig */
+/* detach traced process; continue with sig
+   Never call DETACH twice on the same process as both unattached and
+   attached-unstopped processes give the same ESRCH.  For unattached process we
+   would SIGSTOP it and wait for its SIGSTOP notification forever.  */
 
 static int
 detach(tcp, sig)
@@ -1460,8 +1464,10 @@ int sig;
 	droptcb(tcp);
 
 #ifdef LINUX
-	if (zombie != NULL)
-		error = detach(zombie) || error;
+	if (zombie != NULL) {
+		/* TCP no longer exists therefore you must not detach () it.  */
+		droptcb(zombie);
+	}
 #endif
 
 	return error;
@@ -2035,7 +2041,8 @@ handle_group_exit(struct tcb *tcp, int s
 			fprintf(stderr,
 				"PANIC: handle_group_exit: %d leader %d\n",
 				tcp->pid, leader ? leader->pid : -1);
-		detach(tcp);	/* Already died.  */
+		/* TCP no longer exists therefore you must not detach () it.  */
+		droptcb(tcp);	/* Already died.  */
 	}
 	else {
 		/* Mark that we are taking the process down.  */
@@ -2060,7 +2067,9 @@ handle_group_exit(struct tcb *tcp, int s
 						fprintf(stderr,
 							" [%d exit %d kills %d]\n",
 							tcp->pid, sig, leader->pid);
-					detach(leader, sig);
+					/* LEADER no longer exists therefore you
+					   must not detach () it.  */
+					droptcb(leader);
 				}
 				else
 					leader->flags |= TCB_GROUP_EXITING;


More information about the Strace-devel mailing list