Messages in this thread | | | Subject | Re: zombie with CLONE_THREAD | From | Andreas Schwab <> | Date | Wed, 30 Jun 2004 11:04:46 +0200 |
| |
Roland McGrath <roland@redhat.com> writes:
> Are you saying that if the ptracer dies, it can leave some threads in limbo? > I think that case is supposed to work because forget_original_parent will > move all the threads ptrace'd by the dying tracer process to be ptrace'd by > init, which will then clean up their zombies as previously described.
Here is the test case, run it with "strace -f ./clone". When the bug happens then strace is stuck waiting for it's traced child that just died, but you may have to try a few times before it happens.
#include <stdio.h> #include <signal.h> #include <sched.h> #include <unistd.h> #include <sys/types.h> #include <sys/mman.h>
extern int __clone (int (*__fn) (void *__arg), void *__child_stack, int __flags, void *__arg, ...); extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base, size_t __child_stack_size, int __flags, void *__arg, ...);
static int thread (void *arg) { write (2, "thread\n", sizeof ("thread\n")); *(volatile int *) 0; return 0; }
#define STACK_SIZE 1024 * 1024 #define CLONE_FLAGS CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM
int main (void) { void *stack = mmap (0, STACK_SIZE, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0); pid_t pid;
#ifdef __ia64__ pid = __clone2 (thread, stack, STACK_SIZE - 64, CLONE_FLAGS, 0); #else pid = __clone (thread, stack + STACK_SIZE - 64, CLONE_FLAGS, 0); #endif printf ("pid = %d\n", pid); sleep (1); return 0; }
Andreas.
-- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
| |