From: Paolo 'Blaisorblade' Giarrusso From: Gerd Knorr , Paolo 'Blaisorblade' Giarrusso Uml was using kill(pid, SIGKILL) instead of ptrace(PTRACE_KILL, pid), which used to work, while being probably undocumented. Due to the changes in 2.6.9 to the ptrace(2) semantics, with the introduction of TASK_TRACED by Roland McGrath, this does not more work, so this patch should fix it. With help of Gerd Knorr report and analysis, and its early fix of this problem. He fixed the problem by sending SIGCONT to the child processes after SIGKILL. Which IMHO should not be needed (I think this is a regression, which he already reported). I improved his one, by replacing the SIGCONT hack with using PTRACE_KILL instead. Signed-off-by: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton --- 25-akpm/arch/um/include/os.h | 1 + 25-akpm/arch/um/kernel/skas/process.c | 2 +- 25-akpm/arch/um/kernel/tt/process_kern.c | 2 +- 25-akpm/arch/um/os-Linux/process.c | 8 ++++++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff -puN arch/um/include/os.h~uml-fix-ptrace-hang-on-269-host-due-to-host-changes arch/um/include/os.h --- 25/arch/um/include/os.h~uml-fix-ptrace-hang-on-269-host-due-to-host-changes 2004-11-03 19:27:46.848668416 -0800 +++ 25-akpm/arch/um/include/os.h 2004-11-03 19:27:46.856667200 -0800 @@ -157,6 +157,7 @@ extern unsigned long os_process_pc(int p extern int os_process_parent(int pid); extern void os_stop_process(int pid); extern void os_kill_process(int pid, int reap_child); +extern void os_kill_ptraced_process(int pid, int reap_child); extern void os_usr1_process(int pid); extern int os_getpid(void); diff -puN arch/um/kernel/skas/process.c~uml-fix-ptrace-hang-on-269-host-due-to-host-changes arch/um/kernel/skas/process.c --- 25/arch/um/kernel/skas/process.c~uml-fix-ptrace-hang-on-269-host-due-to-host-changes 2004-11-03 19:27:46.849668264 -0800 +++ 25-akpm/arch/um/kernel/skas/process.c 2004-11-03 19:27:46.856667200 -0800 @@ -389,7 +389,7 @@ void switch_mm_skas(int mm_fd) void kill_off_processes_skas(void) { #warning need to loop over userspace_pids in kill_off_processes_skas - os_kill_process(userspace_pid[0], 1); + os_kill_ptraced_process(userspace_pid[0], 1); } void init_registers(int pid) diff -puN arch/um/kernel/tt/process_kern.c~uml-fix-ptrace-hang-on-269-host-due-to-host-changes arch/um/kernel/tt/process_kern.c --- 25/arch/um/kernel/tt/process_kern.c~uml-fix-ptrace-hang-on-269-host-due-to-host-changes 2004-11-03 19:27:46.851667960 -0800 +++ 25-akpm/arch/um/kernel/tt/process_kern.c 2004-11-03 19:27:46.857667048 -0800 @@ -82,7 +82,7 @@ void *switch_to_tt(void *prev, void *nex prev_sched = current->thread.prev_sched; if((prev_sched->exit_state == EXIT_ZOMBIE) || (prev_sched->exit_state == EXIT_DEAD)) - os_kill_process(prev_sched->thread.mode.tt.extern_pid, 1); + os_kill_ptraced_process(prev_sched->thread.mode.tt.extern_pid, 1); /* This works around a nasty race with 'jail'. If we are switching * between two threads of a threaded app and the incoming process diff -puN arch/um/os-Linux/process.c~uml-fix-ptrace-hang-on-269-host-due-to-host-changes arch/um/os-Linux/process.c --- 25/arch/um/os-Linux/process.c~uml-fix-ptrace-hang-on-269-host-due-to-host-changes 2004-11-03 19:27:46.853667656 -0800 +++ 25-akpm/arch/um/os-Linux/process.c 2004-11-03 19:27:46.858666896 -0800 @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include "os.h" @@ -94,6 +95,13 @@ void os_kill_process(int pid, int reap_c } +void os_kill_ptraced_process(int pid, int reap_child) +{ + ptrace(PTRACE_KILL, pid); + if(reap_child) + CATCH_EINTR(waitpid(pid, NULL, 0)); +} + void os_usr1_process(int pid) { kill(pid, SIGUSR1); _