aboutsummaryrefslogtreecommitdiff
path: root/drivers/unix/os_unix.cpp
diff options
context:
space:
mode:
authorHein-Pieter van Braam2017-02-09 22:01:45 +0100
committerRémi Verschelde2017-03-18 20:05:57 +0100
commitc67b08300a7fcec8e47af37d7882f78f23bb05e2 (patch)
tree2d9fe4eb40f54cd50ba6e6f1f5f19c1072dff25c /drivers/unix/os_unix.cpp
parent9f536e3962e58162f0b8136ba969c07dcfd8863d (diff)
downloadgodot-c67b08300a7fcec8e47af37d7882f78f23bb05e2.tar.gz
godot-c67b08300a7fcec8e47af37d7882f78f23bb05e2.tar.zst
godot-c67b08300a7fcec8e47af37d7882f78f23bb05e2.zip
Diffstat (limited to 'drivers/unix/os_unix.cpp')
-rw-r--r--drivers/unix/os_unix.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 7fcaab870..ce5712f24 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -115,6 +115,13 @@ int OS_Unix::unix_initialize_audio(int p_audio_driver) {
static MemoryPoolStaticMalloc *mempool_static=NULL;
static MemoryPoolDynamicStatic *mempool_dynamic=NULL;
+// 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() {
@@ -146,6 +153,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() {