From a9eb65e9cf5b57929ff015d5bee7000e984d3a96 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 10 Nov 2024 11:14:15 +0000 Subject: [PATCH] lei_store_err: flush before disabling alarm We must flush the output to ensure the alarm works properly, so the easiest way is to rely on IO::Handle::autoflush rather than calling an explicit close() since the SIG{ALRM} handler may close it. --- lib/PublicInbox/LeiStoreErr.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/PublicInbox/LeiStoreErr.pm b/lib/PublicInbox/LeiStoreErr.pm index c8bc72b68..14efa107e 100644 --- a/lib/PublicInbox/LeiStoreErr.pm +++ b/lib/PublicInbox/LeiStoreErr.pm @@ -27,6 +27,7 @@ sub abort_err_wr { close($err_wr) if $err_wr; undef $err_wr } sub emit ($@) { my ($efh, @msg) = @_; open(local $err_wr, '>&', $efh); # fdopen(dup(fileno($efh)), "w") + $err_wr->autoflush(1); local $SIG{ALRM} = \&abort_err_wr; Time::HiRes::alarm(1.0, 0.1); my $ret = print $err_wr @msg; -- 2.47.3