mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-08 11:55:24 +00:00
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:
parent
af51aa1c0f
commit
f730a9c343
@ -40,6 +40,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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -314,6 +314,7 @@ inline int lx_stat(const char *path, struct stat64 *buf)
|
||||
|
||||
enum {
|
||||
LX_SIGUSR1 = 10, /* used for cancel-blocking mechanism */
|
||||
LX_SIGCHLD = 17, /* child process changed state, i.e., terminated */
|
||||
LX_SIGCANCEL = 32, /* accoring to glibc, this equals SIGRTMIN,
|
||||
used for killing threads */
|
||||
};
|
||||
|
@ -167,6 +167,11 @@ static void adopt_thread(Thread_meta_data *meta_data)
|
||||
*/
|
||||
lx_sigaction(LX_SIGUSR1, empty_signal_handler);
|
||||
|
||||
/*
|
||||
* Prevent children from becoming zombies. (SIG_IGN = 1)
|
||||
*/
|
||||
lx_sigaction(LX_SIGCHLD, (void (*)(int))1);
|
||||
|
||||
/* assign 'Thread_meta_data' pointer to TLS entry */
|
||||
pthread_setspecific(tls_key(), meta_data);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user