From 0a9c7b35be399613eb42ab02884462bc93c545df Mon Sep 17 00:00:00 2001 From: "Hongli Lai (Phusion)" Date: Thu, 3 Dec 2009 20:15:32 +0100 Subject: [PATCH] Reset the signal mask because apparently the web server sets it to something that makes stuff like waitpid() malfunction. --- ext/oxt/system_calls.cpp | 11 +++++++++++ ext/oxt/system_calls.hpp | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ext/oxt/system_calls.cpp b/ext/oxt/system_calls.cpp index 690d7ebb0d..01786abb9f 100644 --- a/ext/oxt/system_calls.cpp +++ b/ext/oxt/system_calls.cpp @@ -42,8 +42,19 @@ interruption_signal_handler(int sig) { void oxt::setup_syscall_interruption_support() { struct sigaction action; + sigset_t signal_set; int ret; + /* Very important! The signal mask is inherited across fork() + * and exec() and we don't know what the parent process did to + * us. At least on OS X, having a signal mask blocking important + * signals can lead to stuff like waitpid() malfunction. + */ + sigemptyset(&signal_set); + do { + ret = sigprocmask(SIG_SETMASK, &signal_set, NULL); + } while (ret == -1 && errno == EINTR); + action.sa_handler = interruption_signal_handler; action.sa_flags = 0; sigemptyset(&action.sa_mask); diff --git a/ext/oxt/system_calls.hpp b/ext/oxt/system_calls.hpp index 4bc709ba6e..903d87eb23 100644 --- a/ext/oxt/system_calls.hpp +++ b/ext/oxt/system_calls.hpp @@ -102,7 +102,8 @@ namespace oxt { * Setup system call interruption support. * This function may only be called once. It installs a signal handler * for INTERRUPTION_SIGNAL, so one should not install a different signal - * handler for that signal after calling this function. + * handler for that signal after calling this function. It also resets + * the process signal mask. * * @warning * After oxt::setup_syscall_interruption_support() is called, sending a signal