about summary refs log tree commit homepage
path: root/lib/PublicInbox/TestCommon.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-04-11 10:53:27 +0000
committerEric Wong <e@yhbt.net>2020-04-15 10:16:05 +0000
commit2e59372029f89ae0e9c68384d6bda0ad50704730 (patch)
tree5e2234a946729a62f5b3354147168a18cf39e755 /lib/PublicInbox/TestCommon.pm
parentb3624fbc0a866e6d953ed8564284833ebfde2ec2 (diff)
downloadpublic-inbox-2e59372029f89ae0e9c68384d6bda0ad50704730.tar.gz
Otherwise, the waitpid(-1, 0) call in Xapcmd::process_queue()
may reap it in a subsequent test when using t/run.perl to reuse
processes for testing.

While we're at it, make Xapcmd::process_queue warn about unknown
PIDs in case other PIDs leak through to us in the future.
Diffstat (limited to 'lib/PublicInbox/TestCommon.pm')
-rw-r--r--lib/PublicInbox/TestCommon.pm6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 6e3e9d8c..e9efbac7 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -319,8 +319,9 @@ sub kill {
 }
 
 sub join {
-        my ($self) = @_;
+        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): $!";
         $ret == $pid or die "waitpid($pid) != $ret";
@@ -333,8 +334,7 @@ sub DESTROY {
                 PublicInbox::TestCommon::wait_for_tail();
                 CORE::kill('TERM', $tail);
         }
-        my $pid = delete $self->{pid} or return;
-        CORE::kill('TERM', $pid);
+        $self->join('TERM');
 }
 
 1;