From 50417b5469245feef84789f0bb540a3780dc14b4 Mon Sep 17 00:00:00 2001
From: Eric Wong <e@80x24.org>
Date: Sat, 25 Sep 2021 05:49:44 +0000
Subject: [PATCH] lei: restore old sigmask before daemon exit

If the event loop fails, we want blocking waitpid (wait4) calls
to be interruptible with SIGTERM via "kill $PID" rather than
SIGKILL.  Though a failing event loop is something we should
avoid...
---
 lib/PublicInbox/LEI.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 9d5a5a46..3ff8a347 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -1346,6 +1346,8 @@ sub lazy_start {
 	# $daemon pipe to `lei' closed, main loop begins:
 	eval { PublicInbox::DS->EventLoop };
 	warn "event loop error: $@\n" if $@;
+	# exit() may trigger waitpid via various DESTROY, ensure interruptible
+	PublicInbox::DS::sig_setmask($oldset);
 	dump_and_clear_log();
 	exit($exit_code // 0);
 }
-- 
2.51.0