From 6ddfa3d33d9ec7508637d9282557e6fe7cfb160d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 4 Sep 2023 10:35:58 +0000 Subject: ds: don't block important signals we don't use Don't block SIGABRT, SIGBUS, SIGFPE, SIGILL nor SIGSEGV since blocking them can hide real bugs in our code or 3rd-party libraries and executables. We'll also leave SIGXCPU and SIGXFSZ unblocked since users may've setup RLIMIT_CPU and RLIMIT_FSIZE, respectively. --- lib/PublicInbox/DS.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/PublicInbox/DS.pm') diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index e89dc430..97546016 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -193,10 +193,16 @@ sub RunTimers { sub sig_setmask { sigprocmask(SIG_SETMASK, @_) or die "sigprocmask: $!" } +our @UNBLOCKABLE = map { # ensure we detect bugs, HW problems and user rlimits + my $cb = POSIX->can("SIG$_"); + my $num = $cb ? $cb->() : undef; + $num ? ($num) : (); +} qw(ABRT BUS FPE ILL SEGV XCPU XFSZ); + sub block_signals { # anything in @_ stays unblocked my $newset = POSIX::SigSet->new; $newset->fillset or die "fillset: $!"; - $newset->delset($_) for @_; + for (@_, @UNBLOCKABLE) { $newset->delset($_) or die "delset($_): $!" } my $oldset = POSIX::SigSet->new; sig_setmask($newset, $oldset); $oldset; -- cgit v1.2.3-24-ge0c7