diff --git a/defs.h b/defs.h index d340cbd5..ab24f7cf 100644 --- a/defs.h +++ b/defs.h @@ -368,9 +368,8 @@ struct tcb { struct timeval etime; /* Syscall entry time */ /* Support for tracing forked processes */ struct tcb *parent; /* Parent of this process */ - int nchildren; /* # of traced children */ #ifdef LINUX - int nclone_threads; /* # of nchildren with CLONE_THREAD */ + int nclone_threads; /* # of children with CLONE_THREAD */ #endif /* (1st arg of wait4()) */ long baddr; /* `Breakpoint' address */ diff --git a/process.c b/process.c index 0584f547..2447452d 100644 --- a/process.c +++ b/process.c @@ -836,7 +836,6 @@ handle_new_child(struct tcb *tcp, int pid, int bpt) sizeof tcpchild->inst); } tcpchild->parent = tcp; - tcp->nchildren++; if (tcpchild->flags & TCB_SUSPENDED) { /* The child was born suspended, due to our having forced CLONE_PTRACE. */ @@ -877,10 +876,8 @@ Process %u resumed (parent %d ready)\n", new thread, there will never be a TCB_CLONE_THREAD process that has children. */ - --tcp->nchildren; tcp = tcp->parent; tcpchild->parent = tcp; - ++tcp->nchildren; } if (call_flags & CLONE_THREAD) { tcpchild->flags |= TCB_CLONE_THREAD; @@ -888,12 +885,10 @@ Process %u resumed (parent %d ready)\n", } if ((call_flags & CLONE_PARENT) && !(call_flags & CLONE_THREAD)) { - --tcp->nchildren; tcpchild->parent = NULL; if (tcp->parent != NULL) { tcp = tcp->parent; tcpchild->parent = tcp; - ++tcp->nchildren; } } } @@ -1023,7 +1018,6 @@ internal_fork(struct tcb *tcp) sizeof tcpchild->inst); } tcpchild->parent = tcp; - tcp->nchildren++; if (!qflag) fprintf(stderr, "Process %d attached\n", pid); } diff --git a/strace.c b/strace.c index 6fb6fd6e..94559a5c 100644 --- a/strace.c +++ b/strace.c @@ -514,7 +514,6 @@ startup_attach(void) else if (tid != tcbtab[tcbi]->pid) { tcp = alloctcb(tid); tcp->flags |= TCB_ATTACHED|TCB_CLONE_THREAD|TCB_FOLLOWFORK; - tcbtab[tcbi]->nchildren++; tcbtab[tcbi]->nclone_threads++; tcp->parent = tcbtab[tcbi]; } @@ -1284,7 +1283,6 @@ alloc_tcb(int pid, int command_options_parsed) if ((tcp->flags & TCB_INUSE) == 0) { tcp->pid = pid; tcp->parent = NULL; - tcp->nchildren = 0; #ifdef TCB_CLONE_THREAD tcp->nclone_threads = 0; #endif @@ -1662,15 +1660,14 @@ droptcb(struct tcb *tcp) tcp->pid = 0; if (tcp->parent != NULL) { - tcp->parent->nchildren--; #ifdef TCB_CLONE_THREAD if (tcp->flags & TCB_CLONE_THREAD) tcp->parent->nclone_threads--; #endif #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 + /* Update 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 &&