about summary refs log tree commit homepage
path: root/lib/PublicInbox/SpawnPP.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-06-21 02:39:27 +0000
committerEric Wong <e@80x24.org>2016-06-21 02:40:44 +0000
commitb04e5cf1bc8969cca74ef764f2de960b1ea821a4 (patch)
tree2be20349c2691c020e1e5e901081b87d38383823 /lib/PublicInbox/SpawnPP.pm
parenta07ac38854c1308c4b58e13253527ec3b5e7e1f9 (diff)
downloadpublic-inbox-b04e5cf1bc8969cca74ef764f2de960b1ea821a4.tar.gz
fork failures are unfortunately common when Xapian has
gigabytes and gigabytes mmapped.
Diffstat (limited to 'lib/PublicInbox/SpawnPP.pm')
-rw-r--r--lib/PublicInbox/SpawnPP.pm6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/PublicInbox/SpawnPP.pm b/lib/PublicInbox/SpawnPP.pm
index 36223e81..179aba5e 100644
--- a/lib/PublicInbox/SpawnPP.pm
+++ b/lib/PublicInbox/SpawnPP.pm
@@ -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;
 }