about summary refs log tree commit homepage
path: root/lib/PublicInbox
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r--lib/PublicInbox/Spawn.pm11
-rw-r--r--lib/PublicInbox/SpawnPP.pm5
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm
index 888283d0..f90d8f6d 100644
--- a/lib/PublicInbox/Spawn.pm
+++ b/lib/PublicInbox/Spawn.pm
@@ -78,7 +78,7 @@ int pi_fork_exec(SV *redirref, SV *file, SV *cmdref, SV *envref, SV *rlimref,
         const char *filename = SvPV_nolen(file);
         pid_t pid;
         char **argv, **envp;
-        sigset_t set, old;
+        sigset_t set, old, cset;
         int ret, perrnum, cerrnum = 0;
 
         AV2C_COPY(argv, cmd);
@@ -88,6 +88,10 @@ int pi_fork_exec(SV *redirref, SV *file, SV *cmdref, SV *envref, SV *rlimref,
         assert(ret == 0 && "BUG calling sigfillset");
         ret = sigprocmask(SIG_SETMASK, &set, &old);
         assert(ret == 0 && "BUG calling sigprocmask to block");
+        ret = sigemptyset(&cset);
+        assert(ret == 0 && "BUG calling sigemptyset");
+        ret = sigaddset(&cset, SIGCHLD);
+        assert(ret == 0 && "BUG calling sigaddset for SIGCHLD");
         pid = vfork();
         if (pid == 0) {
                 int sig;
@@ -120,9 +124,10 @@ int pi_fork_exec(SV *redirref, SV *file, SV *cmdref, SV *envref, SV *rlimref,
                 }
 
                 /*
-                 * don't bother unblocking, we don't want signals
-                 * to the group taking out a subprocess
+                 * don't bother unblocking other signals for now, just SIGCHLD.
+                 * we don't want signals to the group taking out a subprocess
                  */
+                (void)sigprocmask(SIG_UNBLOCK, &cset, NULL);
                 execve(filename, argv, envp);
                 exit_err(&cerrnum);
         }
diff --git a/lib/PublicInbox/SpawnPP.pm b/lib/PublicInbox/SpawnPP.pm
index 34ce2052..a72d5a2d 100644
--- a/lib/PublicInbox/SpawnPP.pm
+++ b/lib/PublicInbox/SpawnPP.pm
@@ -36,6 +36,11 @@ sub pi_fork_exec ($$$$$$) {
                 if ($cd ne '') {
                         chdir $cd or die "chdir $cd: $!";
                 }
+                $SIG{$_} = 'DEFAULT' for keys %SIG;
+                my $cset = POSIX::SigSet->new();
+                $cset->addset(POSIX::SIGCHLD) or die "can't add SIGCHLD: $!";
+                sigprocmask(SIG_UNBLOCK, $cset) or
+                                        die "can't unblock SIGCHLD: $!";
                 if ($ENV{MOD_PERL}) {
                         exec which('env'), '-i', @$env, @$cmd;
                         die "exec env -i ... $cmd->[0] failed: $!\n";