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/IPC.pm2
-rw-r--r--lib/PublicInbox/LEI.pm7
-rw-r--r--lib/PublicInbox/TestCommon.pm3
3 files changed, 9 insertions, 3 deletions
diff --git a/lib/PublicInbox/IPC.pm b/lib/PublicInbox/IPC.pm
index 9331233a..efac4c4d 100644
--- a/lib/PublicInbox/IPC.pm
+++ b/lib/PublicInbox/IPC.pm
@@ -412,9 +412,11 @@ sub DESTROY {
         my ($self) = @_;
         my $ppid = $self->{-wq_ppid};
         wq_kill($self) if $ppid && $ppid == $$;
+        my $err = $?;
         wq_close($self);
         wq_wait_old($self);
         ipc_worker_stop($self);
+        $? = $err if $err;
 }
 
 sub detect_nproc () {
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 5f265087..dd831c54 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -336,8 +336,9 @@ sub x_it ($$) {
                         my $wq = delete $self->{$f} or next;
                         $wq->DESTROY;
                 }
-                # cleanup anything that has tempfiles
-                delete @$self{qw(ovv dedupe)};
+                # cleanup anything that has tempfiles or open file handles
+                %PATH2CFG = ();
+                delete @$self{qw(ovv dedupe sto cfg)};
                 if (my $signum = ($code & 127)) { # usually SIGPIPE (13)
                         $SIG{PIPE} = 'DEFAULT'; # $SIG{$signum} doesn't work
                         kill $signum, $$;
@@ -1072,8 +1073,10 @@ sub DESTROY {
         my ($self) = @_;
         $self->{1}->autoflush(1) if $self->{1};
         stop_pager($self);
+        my $err = $?;
         my $oneshot_pids = delete $self->{"pid.$self.$$"} or return;
         waitpid($_, 0) for keys %$oneshot_pids;
+        $? = $err if $err; # preserve ->fail or ->x_it code
 }
 
 1;
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 53f13437..63d45ac3 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -541,7 +541,6 @@ sub setup_public_inboxes () {
         my $end = $lk->lock_for_scope;
         return @ret if -f $stamp;
 
-        require PublicInbox::InboxWritable;
         local $ENV{PI_CONFIG} = $pi_config;
         for my $V (1, 2) {
                 run_script([qw(-init), "-V$V", "t$V",
@@ -549,6 +548,8 @@ sub setup_public_inboxes () {
                                 "$test_home/t$V", "http://example.com/t$V",
                                 "t$V\@example.com" ]) or BAIL_OUT "init v$V";
         }
+        require PublicInbox::Config;
+        require PublicInbox::InboxWritable;
         my $cfg = PublicInbox::Config->new;
         my $seen = 0;
         $cfg->each_inbox(sub {