Linux: prevent zombie state for child processes

Setting the handler for SIGCHLD to SIG_IGN (ignore) informs the kernel
not to enter the zombie state: (man 2 wait)

  POSIX.1-2001 specifies that if the disposition of SIGCHLD is set to
  SIG_IGN or the SA_NOCLDWAIT flag is set for SIGCHLD (see
  sigaction(2)), then children that terminate do not become zombies
  [...]

Fixes #271.
This commit is contained in:
Christian Helmuth
2012-07-09 17:51:39 +02:00
parent af51aa1c0f
commit f730a9c343
4 changed files with 16 additions and 0 deletions

View File

@ -32,6 +32,11 @@ static void thread_start(void *)
*/
lx_sigaction(LX_SIGUSR1, empty_signal_handler);
/*
* Prevent children from becoming zombies. (SIG_IGN = 1)
*/
lx_sigaction(LX_SIGCHLD, (void (*)(int))1);
Thread_base::myself()->entry();
sleep_forever();
}