unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] xap_helper.pm: quiet undefined die at shutdown
@ 2023-10-31 20:34 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2023-10-31 20:34 UTC (permalink / raw)
  To: meta

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 | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/XapHelper.pm b/lib/PublicInbox/XapHelper.pm
index 55080abf..f7640f4c 100644
--- a/lib/PublicInbox/XapHelper.pm
+++ b/lib/PublicInbox/XapHelper.pm
@@ -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();

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-31 20:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-31 20:34 [PATCH] xap_helper.pm: quiet undefined die at shutdown Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).