Permalink
Browse files

Reset the signal mask because apparently the web server sets it to so…

…mething that makes stuff like waitpid() malfunction.
  • Loading branch information...
FooBarWidget committed Dec 3, 2009
1 parent 565470a commit 0a9c7b35be399613eb42ab02884462bc93c545df
Showing with 13 additions and 1 deletion.
  1. +11 −0 ext/oxt/system_calls.cpp
  2. +2 −1 ext/oxt/system_calls.hpp
View
@@ -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);
View
@@ -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

0 comments on commit 0a9c7b3

Please sign in to comment.