about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-10-17 09:30:53 +0000
committerEric Wong <e@80x24.org>2022-10-17 22:16:45 +0000
commit0881010d123914be5e47544229e2b03412a6a691 (patch)
tree283f5c806bfa9ac930b40d61d3aa5f7057093547 /lib
parent7a13b24e3b7f31a647ea180d5b180d8f8eaa025a (diff)
downloadpublic-inbox-0881010d123914be5e47544229e2b03412a6a691.tar.gz
SIGWINCH is actually different for these architectures on Linux
according to the signal(7) man page.

Note: AFAICS there's no parisc machine in the GCC Farm[1],
so it remains untested.  I've only tested mips64 for mips,
but I expect them to both work.

OpenBSD (on gcc231) octeon defines SIGWINCH as the common `28',
so it appears Linux is the only one with arch-dependent signal
numbers (ditto with syscalls).

[1] https://cfarm.tetaneutral.net/machines/list/
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Sigfd.pm13
-rw-r--r--lib/PublicInbox/Syscall.pm5
2 files changed, 8 insertions, 10 deletions
diff --git a/lib/PublicInbox/Sigfd.pm b/lib/PublicInbox/Sigfd.pm
index 583f9f14..3d964be3 100644
--- a/lib/PublicInbox/Sigfd.pm
+++ b/lib/PublicInbox/Sigfd.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # Wraps a signalfd (or similar) for PublicInbox::DS
@@ -6,7 +6,7 @@
 package PublicInbox::Sigfd;
 use strict;
 use parent qw(PublicInbox::DS);
-use PublicInbox::Syscall qw(signalfd EPOLLIN EPOLLET);
+use PublicInbox::Syscall qw(signalfd EPOLLIN EPOLLET %SIGNUM);
 use POSIX ();
 
 # returns a coderef to unblock signals if neither signalfd or kqueue
@@ -14,13 +14,8 @@ use POSIX ();
 sub new {
         my ($class, $sig, $nonblock) = @_;
         my %signo = map {;
-                my $cb = $sig->{$_};
-                # SIGWINCH is 28 on FreeBSD, NetBSD, OpenBSD, Darwin
-                my $num = ($_ eq 'WINCH' && $^O =~ /linux|bsd|darwin/i) ? 28 : do {
-                        my $m = "SIG$_";
-                        POSIX->$m;
-                };
-                $num => $cb;
+                # $num => $cb;
+                ($SIGNUM{$_} // POSIX->can("SIG$_")->()) => $sig->{$_}
         } keys %$sig;
         my $self = bless { sig => \%signo }, $class;
         my $io;
diff --git a/lib/PublicInbox/Syscall.pm b/lib/PublicInbox/Syscall.pm
index 291e0489..ee4c6107 100644
--- a/lib/PublicInbox/Syscall.pm
+++ b/lib/PublicInbox/Syscall.pm
@@ -21,13 +21,14 @@ use parent qw(Exporter);
 use POSIX qw(ENOENT ENOSYS EINVAL O_NONBLOCK);
 use Socket qw(SOL_SOCKET SCM_RIGHTS);
 use Config;
+our %SIGNUM = (WINCH => 28); # most Linux, {Free,Net,Open}BSD, *Darwin
 
 # $VERSION = '0.25'; # Sys::Syscall version
 our @EXPORT_OK = qw(epoll_ctl epoll_create epoll_wait
                   EPOLLIN EPOLLOUT EPOLLET
                   EPOLL_CTL_ADD EPOLL_CTL_DEL EPOLL_CTL_MOD
                   EPOLLONESHOT EPOLLEXCLUSIVE
-                  signalfd rename_noreplace);
+                  signalfd rename_noreplace %SIGNUM);
 our %EXPORT_TAGS = (epoll => [qw(epoll_ctl epoll_create epoll_wait
                              EPOLLIN EPOLLOUT
                              EPOLL_CTL_ADD EPOLL_CTL_DEL EPOLL_CTL_MOD
@@ -159,6 +160,7 @@ if ($^O eq "linux") {
         $SYS_epoll_wait   = 226;
         $u64_mod_8        = 1;
         $SYS_signalfd4 = 309;
+        $SIGNUM{WINCH} = 23;
     } elsif ($machine =~ m/^ppc64/) {
         $SYS_epoll_create = 236;
         $SYS_epoll_ctl    = 237;
@@ -252,6 +254,7 @@ if ($^O eq "linux") {
         $SYS_recvmsg = 4177;
         $FS_IOC_GETFLAGS = 0x40046601;
         $FS_IOC_SETFLAGS = 0x80046602;
+        $SIGNUM{WINCH} = 20;
     } else {
         # as a last resort, try using the *.ph files which may not
         # exist or may be wrong