about summary refs log tree commit homepage
path: root/lib/PublicInbox/Sigfd.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-03-21 23:07:31 +0000
committerEric Wong <e@80x24.org>2023-03-25 09:37:53 +0000
commita0f54ff833d0af03d6426f1464d3b51e380bde31 (patch)
treeb9ea9fcdabdbaae872dfa5c8901c0c19adf8d741 /lib/PublicInbox/Sigfd.pm
parent6cd1c4cb956e4e44144bc71f316aa92ff12ddddf (diff)
downloadpublic-inbox-a0f54ff833d0af03d6426f1464d3b51e380bde31.tar.gz
This is consistent with normal Perl %SIG handlers, and allows
-cindex signal handlers to be implemented consistently across
platforms.
Diffstat (limited to 'lib/PublicInbox/Sigfd.pm')
-rw-r--r--lib/PublicInbox/Sigfd.pm10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/PublicInbox/Sigfd.pm b/lib/PublicInbox/Sigfd.pm
index 3d964be3..3c1d3811 100644
--- a/lib/PublicInbox/Sigfd.pm
+++ b/lib/PublicInbox/Sigfd.pm
@@ -4,7 +4,7 @@
 # Wraps a signalfd (or similar) for PublicInbox::DS
 # fields: (sig: hashref similar to %SIG, but signal numbers as keys)
 package PublicInbox::Sigfd;
-use strict;
+use v5.12;
 use parent qw(PublicInbox::DS);
 use PublicInbox::Syscall qw(signalfd EPOLLIN EPOLLET %SIGNUM);
 use POSIX ();
@@ -14,8 +14,8 @@ use POSIX ();
 sub new {
         my ($class, $sig, $nonblock) = @_;
         my %signo = map {;
-                # $num => $cb;
-                ($SIGNUM{$_} // POSIX->can("SIG$_")->()) => $sig->{$_}
+                # $num => [ $cb, $signame ];
+                ($SIGNUM{$_} // POSIX->can("SIG$_")->()) => [ $sig->{$_}, $_ ]
         } keys %$sig;
         my $self = bless { sig => \%signo }, $class;
         my $io;
@@ -45,8 +45,8 @@ sub wait_once ($) {
                 for my $off (0..$nr) {
                         # the first uint32_t of signalfd_siginfo: ssi_signo
                         my $signo = unpack('L', substr($buf, 128 * $off, 4));
-                        my $cb = $self->{sig}->{$signo};
-                        $cb->($signo) if $cb ne 'IGNORE';
+                        my ($cb, $signame) = @{$self->{sig}->{$signo}};
+                        $cb->($signame) if $cb ne 'IGNORE';
                 }
         }
         $r;