warn $@, "\n" if $@;
}
-sub reap_children { # $_[0] = 'CHLD' or POSIX::SIGCHLD()
+sub reap_children { # $_[0] = 'CHLD'
while (1) {
my $p = waitpid(-1, WNOHANG) or return;
if (defined $reexec_pid && $p == $reexec_pid) {
# 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 ();
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;
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;