X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fds-kqxs.t;h=43c71fed8c975ec6b7b148427142c0d7c2a28b48;hb=refs%2Fheads%2Fmaster;hp=785570c35fdd5edda61710d62b9d30c440958b4a;hpb=1e44ee6d429b853a7a87ae58e56241c55ab8c306;p=public-inbox.git diff --git a/t/ds-kqxs.t b/t/ds-kqxs.t index 785570c3..43c71fed 100644 --- a/t/ds-kqxs.t +++ b/t/ds-kqxs.t @@ -1,4 +1,4 @@ -# Copyright (C) 2019 all contributors +# Copyright (C) 2019-2021 all contributors # Licensed the same as Danga::Socket (and Perl5) # License: GPL-1.0+ or Artistic-1.0-Perl # @@ -10,5 +10,33 @@ unless (eval { require IO::KQueue }) { : "no IO::KQueue, skipping $0: $@"; plan skip_all => $m; } + +if ('ensure nested kqueue works for signalfd emulation') { + require POSIX; + my $new = POSIX::SigSet->new(POSIX::SIGHUP()); + my $old = POSIX::SigSet->new; + my $hup = 0; + local $SIG{HUP} = sub { $hup++ }; + POSIX::sigprocmask(POSIX::SIG_SETMASK(), $new, $old) or die; + my $kqs = IO::KQueue->new or die; + $kqs->EV_SET(POSIX::SIGHUP(), IO::KQueue::EVFILT_SIGNAL(), + IO::KQueue::EV_ADD()); + kill('HUP', $$) or die; + my @events = $kqs->kevent(3000); + is(scalar(@events), 1, 'got one event'); + is($events[0]->[0], POSIX::SIGHUP(), 'got SIGHUP'); + my $parent = IO::KQueue->new or die; + my $kqfd = $$kqs; + $parent->EV_SET($kqfd, IO::KQueue::EVFILT_READ(), IO::KQueue::EV_ADD()); + kill('HUP', $$) or die; + @events = $parent->kevent(3000); + is(scalar(@events), 1, 'got one event'); + is($events[0]->[0], $kqfd, 'got kqfd'); + is($hup, 0, '$SIG{HUP} did not fire'); + POSIX::sigprocmask(POSIX::SIG_SETMASK(), $old) or die; + defined(POSIX::close($kqfd)) or die; + defined(POSIX::close($$parent)) or die; +} + local $ENV{TEST_IOPOLLER} = 'PublicInbox::DSKQXS'; require './t/ds-poll.t';