2007-11-06  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* strace.c [LINUX] (droptcb): Recurse on TCP->parent if it is a
	TCB_EXITING zombie group leader.
	* test/childthread.c: New file.
	* test/.cvsignore, test/Makefile: Add it.
	Code advisory: Roland McGrath
	Fixes RH#354261.
diff --git a/strace.c b/strace.c
index b71e093..341ed04 100644
--- a/strace.c
+++ b/strace.c
@@ -1297,6 +1297,16 @@
 		if (!(tcp->flags & TCB_CLONE_DETACHED))
 #endif
 			tcp->parent->nzombies++;
+#ifdef LINUX
+		/* Update `tcp->parent->parent->nchildren' and the other fields
+		   like NCLONE_DETACHED, only for zombie group leader that has
+		   already reported and been short-circuited at the top of this
+		   function.  The same condition as at the top of DETACH.  */
+		if ((tcp->flags & TCB_CLONE_THREAD) &&
+		    tcp->parent->nclone_threads == 0 &&
+		    (tcp->parent->flags & TCB_EXITING))
+			droptcb(tcp->parent);
+#endif
 		tcp->parent = NULL;
 	}