examples/unsubscribe.milter | 3 +--
lib/PublicInbox/DS.pm | 3 +--
lib/PublicInbox/Daemon.pm | 2 +-
lib/PublicInbox/Sigfd.pm | 3 +--
t/epoll.t | 7 +++++--
diff --git a/examples/unsubscribe.milter b/examples/unsubscribe.milter
index 7b126e3094e4f0e2b46aebc81bae952d8dadfaec..608524cbaca40337a8ca45a1f0b7d0ba38cfd774 100644
--- a/examples/unsubscribe.milter
+++ b/examples/unsubscribe.milter
@@ -2,7 +2,6 @@ #!/usr/bin/perl -w
# Copyright (C) 2016-2021 all contributors
# License: AGPL-3.0+
use strict;
-use warnings;
use Sendmail::PMilter qw(:all);
use IO::Socket;
use Crypt::CBC;
@@ -128,7 +127,7 @@ my $fds = $ENV{LISTEN_FDS};
if ($fds && (($ENV{LISTEN_PID} || 0) == $$)) {
die "$0 can only listen on one FD\n" if $fds != 1;
my $start_fd = 3;
- my $s = IO::Socket->new_from_fd($start_fd, 'r') or
+ open(my $s, '<&=', $start_fd) or
die "inherited bad FD from LISTEN_FDS: $!\n";
$milter->set_socket($s);
} else {
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 3cddfd188588e0fc8f13163b0150478e01304514..7a4dfed06242320f28dcb7decbfe3a76a8bcd535 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -25,7 +25,6 @@ use v5.10.1;
use parent qw(Exporter);
use bytes;
use POSIX qw(WNOHANG sigprocmask SIG_SETMASK);
-use IO::Handle qw();
use Fcntl qw(SEEK_SET :DEFAULT O_APPEND);
use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
use Scalar::Util qw(blessed);
@@ -135,7 +134,7 @@ # epoll_create1(EPOLL_CLOEXEC) requires Linux 2.6.27+...
sub set_cloexec ($) {
my ($fd) = @_;
- $_io = IO::Handle->new_from_fd($fd, 'r+') or return;
+ open($_io, '+<&=', $fd) or return;
defined(my $fl = fcntl($_io, F_GETFD, 0)) or return;
fcntl($_io, F_SETFD, $fl | FD_CLOEXEC);
}
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index b5f97d81bebf57256a3b3a520c1a95dd37b87d93..727311a4aa10eb8d97612022869f3ce9f2e15c5b 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -367,7 +367,7 @@ my $fds = $ENV{LISTEN_FDS} or return ();
my $end = $fds + 2; # LISTEN_FDS_START - 1
my @rv = ();
foreach my $fd (3..$end) {
- my $s = IO::Handle->new_from_fd($fd, 'r');
+ open(my $s, '<&=', $fd) or warn "fdopen fd=$fd: $!";
if (my $k = sockname($s)) {
my $prev_was_blocking = $s->blocking(0);
warn <<"" if $prev_was_blocking;
diff --git a/lib/PublicInbox/Sigfd.pm b/lib/PublicInbox/Sigfd.pm
index a4d1b3bba81a26bc9a74e91a630d824c7ae1aa57..d91ea0e7ac78ae541edabc7b647c78224a48e3cc 100644
--- a/lib/PublicInbox/Sigfd.pm
+++ b/lib/PublicInbox/Sigfd.pm
@@ -8,7 +8,6 @@ use strict;
use parent qw(PublicInbox::DS);
use PublicInbox::Syscall qw(signalfd EPOLLIN EPOLLET SFD_NONBLOCK);
use POSIX ();
-use IO::Handle ();
# returns a coderef to unblock signals if neither signalfd or kqueue
# are available.
@@ -27,7 +26,7 @@ my $self = bless { sig => \%signo }, $class;
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 {
diff --git a/t/epoll.t b/t/epoll.t
index f2a68904a5b3ceb221746c18f7c180c84805f267..f346b3871fd682c462752717e202fa4290847cba 100644
--- a/t/epoll.t
+++ b/t/epoll.t
@@ -1,11 +1,14 @@
+#!perl -w
+# Copyright (C) 2020-2021 all contributors
+# License: AGPL-3.0+
use strict;
+use v5.10.1;
use Test::More;
-use IO::Handle;
use PublicInbox::Syscall qw(:epoll);
plan skip_all => 'not Linux' if $^O ne 'linux';
my $epfd = epoll_create();
ok($epfd >= 0, 'epoll_create');
-my $hnd = IO::Handle->new_from_fd($epfd, 'r+'); # close on exit
+open(my $hnd, '+<&=', $epfd); # for autoclose
pipe(my ($r, $w)) or die "pipe: $!";
is(epoll_ctl($epfd, EPOLL_CTL_ADD, fileno($w), EPOLLOUT), 0,