]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Sigfd.pm
treewide: favor open(..., '+<&=', $fd)
[public-inbox.git] / lib / PublicInbox / Sigfd.pm
index bf91bb3774f1b71939ef18283ca344834bfb61e5..d91ea0e7ac78ae541edabc7b647c78224a48e3cc 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2019-2021 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
@@ -7,8 +7,7 @@ package PublicInbox::Sigfd;
 use strict;
 use parent qw(PublicInbox::DS);
 use PublicInbox::Syscall qw(signalfd EPOLLIN EPOLLET SFD_NONBLOCK);
-use POSIX qw(:signal_h);
-use IO::Handle ();
+use POSIX ();
 
 # returns a coderef to unblock signals if neither signalfd or kqueue
 # are available.
@@ -27,7 +26,7 @@ sub new {
        my $io;
        my $fd = signalfd(-1, [keys %signo], $flags);
        if (defined $fd && $fd >= 0) {
-               $io = IO::Handle->new_from_fd($fd, 'r+');
+               open($io, '+<&=', $fd) or die "open: $!";
        } elsif (eval { require PublicInbox::DSKQXS }) {
                $io = PublicInbox::DSKQXS->signalfd([keys %signo], $flags);
        } else {
@@ -63,14 +62,4 @@ sub event_step {
        while (wait_once($_[0])) {} # non-blocking
 }
 
-sub sig_setmask { sigprocmask(SIG_SETMASK, @_) or die "sigprocmask: $!" }
-
-sub block_signals () {
-       my $oldset = POSIX::SigSet->new;
-       my $newset = POSIX::SigSet->new;
-       $newset->fillset or die "fillset: $!";
-       sig_setmask($newset, $oldset);
-       $oldset;
-}
-
 1;