From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id AA9D21F51E; Mon, 17 Oct 2022 09:30:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1665999053; bh=UbbocCbsli7qFqTAsWYRzPEymBupvkyEkL4c5wzzUvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kbapFhSgCf3wMmfeMWNzuZ5x61LKRhdX2tNZNB0vmKrA2eWj9ye5KhKXTW+qq/KFR dIjPfZ02VKfaxpvdaiMW+U9VExG0LRiWQ8lErl4S5rP8xZhTfark6B+n42iaTjWnW+ uD0lY/hnjBYp7Aa90Lk+6T8mLSmwaoopVloV+35g= From: Eric Wong To: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Cc: meta@public-inbox.org Subject: [PATCH 2/2] sigfd: set SIGWINCH for MIPS and PA-RISC on Linux Date: Mon, 17 Oct 2022 09:30:53 +0000 Message-Id: <20221017093053.1517046-3-e@80x24.org> In-Reply-To: <20221015081246.18167-1-n.oje.bar@gmail.com> References: <20221015081246.18167-1-n.oje.bar@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 syscall numbers. [1] https://cfarm.tetaneutral.net/machines/list/ --- devel/syscall-list | 2 ++ lib/PublicInbox/Sigfd.pm | 13 ++++--------- lib/PublicInbox/Syscall.pm | 5 ++++- t/sigfd.t | 5 ++++- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/devel/syscall-list b/devel/syscall-list index adb450da..0b36c0e2 100755 --- a/devel/syscall-list +++ b/devel/syscall-list @@ -26,6 +26,7 @@ system($cc, '-o', $x, $f, @cflags) == 0 or die "cc failed \$?=$?"; exec($x); __DATA__ #define _GNU_SOURCE +#include #include #include #ifdef __linux__ @@ -65,5 +66,6 @@ int main(void) #endif /* Linux, any other OSes with stable syscalls? */ printf("size_t=%zu off_t=%zu pid_t=%zu\n", sizeof(size_t), sizeof(off_t), sizeof(pid_t)); + D(SIGWINCH); return 0; } 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 +# Copyright (C) all contributors # License: AGPL-3.0+ # 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 diff --git a/t/sigfd.t b/t/sigfd.t index a68b12a6..7eb6b222 100644 --- a/t/sigfd.t +++ b/t/sigfd.t @@ -18,7 +18,8 @@ SKIP: { local $SIG{HUP} = sub { $hit->{HUP}->{normal}++ }; local $SIG{TERM} = sub { $hit->{TERM}->{normal}++ }; local $SIG{INT} = sub { $hit->{INT}->{normal}++ }; - for my $s (qw(HUP TERM INT)) { + local $SIG{WINCH} = sub { $hit->{WINCH}->{normal}++ }; + for my $s (qw(HUP TERM INT WINCH)) { $sig->{$s} = sub { $hit->{$s}->{sigfd}++ }; } my $sigfd = PublicInbox::Sigfd->new($sig, 0); @@ -26,6 +27,7 @@ SKIP: { ok($sigfd, 'Sigfd->new works'); kill('HUP', $$) or die "kill $!"; kill('INT', $$) or die "kill $!"; + kill('WINCH', $$) or die "kill $!"; my $fd = fileno($sigfd->{sock}); ok($fd >= 0, 'fileno(Sigfd->{sock}) works'); my $rvec = ''; @@ -54,6 +56,7 @@ SKIP: { PublicInbox::DS->Reset; is($hit->{TERM}->{sigfd}, 1, 'TERM sigfd fired in event loop'); is($hit->{HUP}->{sigfd}, 3, 'HUP sigfd fired in event loop'); + is($hit->{WINCH}->{sigfd}, 1, 'WINCH sigfd fired in event loop'); } else { skip('signalfd disabled?', 10); }