diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-02-12 23:25:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-12 23:25:20 +0100 |
commit | 00b093d24da4f354b4badd15fb4baa9f01b60fd1 (patch) | |
tree | 518f51e7f0acdedda820b8fef20052210e0d0af0 | |
parent | d417e919950f9fb05ab1dbaea291f8ec17c9ffdd (diff) | |
parent | cff6840ff7da010112b94f9be13deaa8288e90cd (diff) |
Merge pull request #7774 from hpvb/master
Add a simple signal handler for SIGCHLD on Unix
-rw-r--r-- | drivers/unix/os_unix.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index cc69283f97..edf5f22714 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -117,7 +117,13 @@ int OS_Unix::unix_initialize_audio(int p_audio_driver) { 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() { @@ -148,6 +154,14 @@ void OS_Unix::initialize_core() { ticks_start=0; 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() { |