]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SpawnPP.pm
Merge branch 'thread-view-skel'
[public-inbox.git] / lib / PublicInbox / SpawnPP.pm
index 36223e8132eefa30c380bf1b07fef42bbf40628b..179aba5e737ccb524947dfd424d208c2618abed8 100644 (file)
@@ -12,7 +12,12 @@ sub public_inbox_fork_exec ($$$$$$) {
        my $set = POSIX::SigSet->new();
        $set->fillset or die "fillset failed: $!";
        sigprocmask(SIG_SETMASK, $set, $old) or die "can't block signals: $!";
+       my $syserr;
        my $pid = fork;
+       unless (defined $pid) { # compat with Inline::C version
+               $syserr = $!;
+               $pid = -1;
+       }
        if ($pid == 0) {
                if ($in != 0) {
                        dup2($in, 0) or die "dup2 failed for stdin: $!";
@@ -34,6 +39,7 @@ sub public_inbox_fork_exec ($$$$$$) {
                }
        }
        sigprocmask(SIG_SETMASK, $old) or die "can't unblock signals: $!";
+       $! = $syserr;
        $pid;
 }