]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
xap_helper.pm: quiet undefined die at shutdown
authorEric Wong <e@80x24.org>
Tue, 31 Oct 2023 20:34:51 +0000 (20:34 +0000)
committerEric Wong <e@80x24.org>
Wed, 1 Nov 2023 07:08:05 +0000 (07:08 +0000)
Another attempt at doing what commit 35de8fdcbf290e25
(xap_helper.pm: quiet undefined warnings at shutdown, 2023-10-23)
tried to do.  It turns out perl croaks (not warn/carp) when it sees
an undefined file handle, here.

lib/PublicInbox/XapHelper.pm

index 55080abfe0b35e315ea72534d5bb59b755905555..f7640f4c94842321896d37f17b637f8cefd1f2c7 100644 (file)
@@ -179,11 +179,13 @@ sub recv_loop {
        local $SIG{TERM} = sub { undef $in };
        while (defined($in)) {
                PublicInbox::DS::sig_setmask($workerset);
-               my @fds = do { # we undef $in in SIG{TERM}
-                       no strict 'refs';
-                       no warnings 'uninitialized';
+               my @fds = eval { # we undef $in in SIG{TERM}
                        $PublicInbox::IPC::recv_cmd->($in, $rbuf, 4096*33)
                };
+               if ($@) {
+                       exit if !$in; # hit by SIGTERM
+                       die;
+               }
                scalar(@fds) or exit(66); # EX_NOINPUT
                die "recvmsg: $!" if !defined($fds[0]);
                PublicInbox::DS::block_signals();