Skip to content

Commit

Permalink
Reset the signal mask because apparently the web server sets it to so…
Browse files Browse the repository at this point in the history
…mething that makes stuff like waitpid() malfunction.
  • Loading branch information
FooBarWidget committed Dec 12, 2009
1 parent 565470a commit 0a9c7b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions ext/oxt/system_calls.cpp
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion ext/oxt/system_calls.hpp
Expand Up @@ -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
Expand Down

0 comments on commit 0a9c7b3

Please sign in to comment.