Add a simple signal handler for SIGCHLD on Unix

This fixes #6631
This commit is contained in:
Hein-Pieter van Braam 2017-02-09 22:01:45 +01:00
parent b87a232668
commit cff6840ff7

View file

@ -117,7 +117,13 @@ int OS_Unix::unix_initialize_audio(int p_audio_driver) {
return 0; return 0;
} }
// Very simple signal handler to reap processes where ::execute was called with
// !p_blocking
void handle_sigchld(int sig) {
int saved_errno = errno;
while (waitpid((pid_t)(-1), 0, WNOHANG) > 0) {}
errno = saved_errno;
}
void OS_Unix::initialize_core() { void OS_Unix::initialize_core() {
@ -148,6 +154,14 @@ void OS_Unix::initialize_core() {
ticks_start=0; ticks_start=0;
ticks_start=get_ticks_usec(); ticks_start=get_ticks_usec();
struct sigaction sa;
sa.sa_handler = &handle_sigchld;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART | SA_NOCLDSTOP;
if (sigaction(SIGCHLD, &sa, 0) == -1) {
perror("ERROR sigaction() failed:");
}
} }
void OS_Unix::finalize_core() { void OS_Unix::finalize_core() {