]> granicus.if.org Git - strace/commitdiff
2004-10-19 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Wed, 20 Oct 2004 02:04:15 +0000 (02:04 +0000)
committerRoland McGrath <roland@redhat.com>
Wed, 20 Oct 2004 02:04:15 +0000 (02:04 +0000)
* strace.c (handle_group_exit): Don't detach leader that wasn't
TCB_ATTACHED.  Instead mark it with TCB_GROUP_EXITING.
Remove droptcb loop at end, no longer required since 2.6 reports each
thread death.
Fixes RH#135254.

strace.c

index ce7701e306ac227ca5491f29464bf95dd5170404..70efbb5cd1a1a345ceb4502e34c14224df814def 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -1926,8 +1926,6 @@ handle_group_exit(struct tcb *tcp, int sig)
                              ? tcp->parent
                              : tcp->nclone_detached > 0
                              ? tcp : NULL);
-       fprintf(stderr,"handle_group_exit (%d [%d], %d)\n", tcp->pid,
-               leader? leader->pid:-1, sig);
 
        if (sig < 0) {
                if (leader != NULL && leader != tcp &&
@@ -1939,23 +1937,29 @@ handle_group_exit(struct tcb *tcp, int sig)
        }
        else {
                if (tcp->flags & TCB_ATTACHED) {
-                       if (leader != NULL && leader != tcp &&
-                               (leader->flags & TCB_ATTACHED)) {
-                               /* We need to detach the leader so that the
-                                  process death will be reported to its real
-                                  parent.  But we kill it first to prevent
-                                  it doing anything before we kill the whole
-                                  process in a moment.  We can use
-                                  PTRACE_KILL on a thread that's not already
-                                  stopped.  Then the value we pass in
-                                  PTRACE_DETACH just sets the death
-                                  signal reported to the real parent.  */
-                               ptrace(PTRACE_KILL, leader->pid, 0, 0);
-                               if (debug)
-                                       fprintf(stderr,
-                                               " [%d exit %d kills %d]\n",
-                                               tcp->pid, sig, leader->pid);
-                               detach(leader, sig);
+                       if (leader != NULL && leader != tcp) {
+                               if (leader->flags & TCB_ATTACHED) {
+                                       /* We need to detach the leader so
+                                          that the process death will be
+                                          reported to its real parent.
+                                          But we kill it first to prevent
+                                          it doing anything before we kill
+                                          the whole process in a moment.
+                                          We can use PTRACE_KILL on a
+                                          thread that's not already
+                                          stopped.  Then the value we pass
+                                          in PTRACE_DETACH just sets the
+                                          death signal reported to the
+                                          real parent.  */
+                                       ptrace(PTRACE_KILL, leader->pid, 0, 0);
+                                       if (debug)
+                                               fprintf(stderr,
+                                                       " [%d exit %d kills %d]\n",
+                                                       tcp->pid, sig, leader->pid);
+                                       detach(leader, sig);
+                               }
+                               else
+                                       leader->flags |= TCB_GROUP_EXITING;
                        }
                        detach(tcp, sig);
                }
@@ -1975,18 +1979,6 @@ handle_group_exit(struct tcb *tcp, int sig)
                }
        }
 
-       /* Note that TCP and LEADER are no longer valid,
-          but we can still compare against them.  */
-       if (leader != NULL) {
-               unsigned int i;
-               for (i = 0; i < tcbtabsize; i++) {
-                       struct tcb *t = tcbtab[i];
-                       if (t != tcp && (t->flags & TCB_CLONE_DETACHED)
-                           && t->parent == leader)
-                               droptcb(t);
-               }
-       }
-
        return 0;
 }
 #endif