de_thread()
PATCH RESEND 1/1 de_thread()
Hello.
Quoted 8 lines · Oleg Nesterov
Suppose process P in thread group was cloned _without_
CLONE_DETACHEDflag. Then another thread,group_leaderfor simplicity, does exec and callsde_thread(). It kills P via_broadcast_thread_group(). While doingdo_exit(), P skipsrelease_task(), because itsexit_signal!= -1, and becomesTASK_ZOMBIE.
Quoted 4 lines
Then leader calls
schedule()withTASK_UNINTERRUPTIBLEinwhile(oldsig->count > 1){...} and sleeps forever, because nobody can dowake_up_process(sig->group_exit_task).
This program should hang leaving task in D state.
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <asm/unistd.h>
#define CLONE_SIGHAND 0x00000800
#define CLONE_THREAD 0x00010000
#define __NR_sys_clone __NR_clone
static inline _syscall2(int,sys_clone, int,flag, void*,stack)
int main(void)
{
static char stack[1024];
int pid = sys_clone(CLONE_THREAD | CLONE_SIGHAND | SIGCHLD, stack);
if (pid < 0) {
printf("ERR!! clone: %s.\n", strerror(errno));
return -1;
}
if (pid == 0) _exit(0);
execlp("echo", "echo", "Should not happen.", 0);
printf("ERR!! exec: %s.\n", strerror(errno));
return 0;
}Oleg.