about summary refs log tree commit homepage
path: root/lib/PublicInbox/TestCommon.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-01-24 22:41:58 -0800
committerEric Wong <e@80x24.org>2021-01-26 18:51:31 +0000
commitda86f10a548d4cce25f91bb4063f82ecbbe441a1 (patch)
treee19b26c90c73a05fd08f5f9796fb5fcb57563200 /lib/PublicInbox/TestCommon.pm
parent99d3f175072a8ef062ba6335a3ceb267ba89c12b (diff)
downloadpublic-inbox-da86f10a548d4cce25f91bb4063f82ecbbe441a1.tar.gz
Mainly around fork() calls, but some nearby places as well.
Diffstat (limited to 'lib/PublicInbox/TestCommon.pm')
-rw-r--r--lib/PublicInbox/TestCommon.pm10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 16ae2650..40c2dc9e 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -254,8 +254,7 @@ sub run_script ($;$$) {
                 my $cmd = [ key2script($key), @argv ];
                 my $pid = PublicInbox::Spawn::spawn($cmd, $env, $spawn_opt);
                 if (defined $pid) {
-                        my $r = waitpid($pid, 0);
-                        defined($r) or die "waitpid: $!";
+                        my $r = waitpid($pid, 0) // die "waitpid: $!";
                         $r == $pid or die "waitpid: expected $pid, got $r";
                 }
         } else { # localize and run everything in the same process:
@@ -367,7 +366,7 @@ sub start_script {
                         }
                 }
                 if (@paths) {
-                        defined($tail_pid = fork) or die "fork: $!\n";
+                        $tail_pid = fork // die "fork: $!";
                         if ($tail_pid == 0) {
                                 # make sure files exist, first
                                 open my $fh, '>>', $_ for @paths;
@@ -378,7 +377,7 @@ sub start_script {
                         wait_for_tail($tail_pid, scalar @paths);
                 }
         }
-        defined(my $pid = fork) or die "fork: $!\n";
+        my $pid = fork // die "fork: $!\n";
         if ($pid == 0) {
                 eval { PublicInbox::DS->Reset };
                 # pretend to be systemd (cf. sd_listen_fds(3))
@@ -440,8 +439,7 @@ sub join {
         my ($self, $sig) = @_;
         my $pid = delete $self->{pid} or return;
         CORE::kill($sig, $pid) if defined $sig;
-        my $ret = waitpid($pid, 0);
-        defined($ret) or die "waitpid($pid): $!";
+        my $ret = waitpid($pid, 0) // die "waitpid($pid): $!";
         $ret == $pid or die "waitpid($pid) != $ret";
 }