Re: Unkillable processes due to PTRACE_TRACEME again

From: Oleg Nesterov
Date: Mon Dec 05 2016 - 05:47:18 EST


On 12/02, Dmitry Vyukov wrote:
>
> I am not on 2caceb3294a78c389b462e7e236a4e744a53a474 (Dec 1). And see
> the same unwaitable zombie processes.

This is another thing, and notabug. This is how ptrace works,

> void *thr(void *arg)
> {
> ptrace(PTRACE_TRACEME, 0, 0, 0);
> }
>
> int main()
> {
> int pid = fork();
> if (pid == 0) {
> pthread_t th;
> pthread_create(&th, 0, thr, 0);
> usleep(100000);
> exit(0);
> }
> usleep(200000);
> kill(pid, SIGKILL);
> int status = 0;
> waitpid(pid, &status, __WALL);

waitpid(pid) hangs because you need to reap the sub-thread first.

Oleg.