]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
ds: don't block important signals we don't use
authorEric Wong <e@80x24.org>
Mon, 4 Sep 2023 10:35:58 +0000 (10:35 +0000)
committerEric Wong <e@80x24.org>
Tue, 5 Sep 2023 03:01:35 +0000 (03:01 +0000)
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

index e89dc4306c7b62b6227d90bca098315305fbe035..97546016e9815c492ec41452d62af51cef43f4b6 100644 (file)
@@ -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;