1 # Copyright (C) 2019-2021 all contributors <meta@public-inbox.org>
2 # Licensed the same as Danga::Socket (and Perl5)
3 # License: GPL-1.0+ or Artistic-1.0-Perl
4 # <https://www.gnu.org/licenses/gpl-1.0.txt>
5 # <https://dev.perl.org/licenses/artistic.html>
8 unless (eval { require IO::KQueue }) {
9 my $m = $^O !~ /bsd/ ? 'DSKQXS is only for *BSD systems'
10 : "no IO::KQueue, skipping $0: $@";
14 if ('ensure nested kqueue works for signalfd emulation') {
16 my $new = POSIX::SigSet->new(POSIX::SIGHUP());
17 my $old = POSIX::SigSet->new;
19 local $SIG{HUP} = sub { $hup++ };
20 POSIX::sigprocmask(POSIX::SIG_SETMASK(), $new, $old) or die;
21 my $kqs = IO::KQueue->new or die;
22 $kqs->EV_SET(POSIX::SIGHUP(), IO::KQueue::EVFILT_SIGNAL(),
23 IO::KQueue::EV_ADD());
24 kill('HUP', $$) or die;
25 my @events = $kqs->kevent(3000);
26 is(scalar(@events), 1, 'got one event');
27 is($events[0]->[0], POSIX::SIGHUP(), 'got SIGHUP');
28 my $parent = IO::KQueue->new or die;
30 $parent->EV_SET($kqfd, IO::KQueue::EVFILT_READ(), IO::KQueue::EV_ADD());
31 kill('HUP', $$) or die;
32 @events = $parent->kevent(3000);
33 is(scalar(@events), 1, 'got one event');
34 is($events[0]->[0], $kqfd, 'got kqfd');
35 is($hup, 0, '$SIG{HUP} did not fire');
36 POSIX::sigprocmask(POSIX::SIG_SETMASK(), $old) or die;
37 defined(POSIX::close($kqfd)) or die;
38 defined(POSIX::close($$parent)) or die;
41 local $ENV{TEST_IOPOLLER} = 'PublicInbox::DSKQXS';
42 require './t/ds-poll.t';