FD_CLOEXEC is the only currently defined FD flag, and has been
the case for decades at this point. I highly doubt any default
FD flag will ever be forced on us by the kernel, init system, or
Perl. So save ourselves a syscall and just call F_SETFD with
the assumption FD_CLOEXEC is the only FD flag that we'd ever
care for.
my $fd = epoll_create();
die "epoll_create: $!" if $fd < 0;
open($ep_io, '+<&=', $fd) or return;
my $fd = epoll_create();
die "epoll_create: $!" if $fd < 0;
open($ep_io, '+<&=', $fd) or return;
- my $fl = fcntl($ep_io, F_GETFD, 0);
- fcntl($ep_io, F_SETFD, $fl | FD_CLOEXEC);
+ fcntl($ep_io, F_SETFD, FD_CLOEXEC);
use IO::Handle; # ->autoflush
use IO::Socket;
use File::Spec;
use IO::Handle; # ->autoflush
use IO::Socket;
use File::Spec;
-use POSIX qw(WNOHANG :signal_h);
+use POSIX qw(WNOHANG :signal_h F_SETFD);
use Socket qw(IPPROTO_TCP SOL_SOCKET);
STDOUT->autoflush(1);
STDERR->autoflush(1);
use Socket qw(IPPROTO_TCP SOL_SOCKET);
STDOUT->autoflush(1);
STDERR->autoflush(1);
return;
}
if ($pid == 0) {
return;
}
if ($pid == 0) {
- use Fcntl qw(FD_CLOEXEC F_SETFD F_GETFD);
$ENV{LISTEN_FDS} = scalar @listeners;
$ENV{LISTEN_PID} = $$;
foreach my $s (@listeners) {
# @listeners are globs with workers, PI::L w/o workers
$s = $s->{sock} if ref($s) eq 'PublicInbox::Listener';
$ENV{LISTEN_FDS} = scalar @listeners;
$ENV{LISTEN_PID} = $$;
foreach my $s (@listeners) {
# @listeners are globs with workers, PI::L w/o workers
$s = $s->{sock} if ref($s) eq 'PublicInbox::Listener';
-
- my $fl = fcntl($s, F_GETFD, 0);
- fcntl($s, F_SETFD, $fl &= ~FD_CLOEXEC);
+ fcntl($s, F_SETFD, 0) // die "F_SETFD: $!";
}
exec @CMD;
die "Failed to exec: $!\n";
}
exec @CMD;
die "Failed to exec: $!\n";