about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-09-21 11:11:10 +0000
committerEric Wong <e@80x24.org>2015-09-21 11:37:04 +0000
commit326f7412b601e8d0d929026802e469bdb7fe1940 (patch)
tree07809773a67b69fcec8f277b7e6365a78eb12be1 /t
parentf9d88ea6c375f6f265da1a13025abcc9e38d6839 (diff)
downloadpublic-inbox-326f7412b601e8d0d929026802e469bdb7fe1940.tar.gz
The created socket FD number may not be 3 in the test,
force it to be so inside the child process.
Diffstat (limited to 't')
-rw-r--r--t/nntpd.t3
1 files changed, 2 insertions, 1 deletions
diff --git a/t/nntpd.t b/t/nntpd.t
index 527cfc2c..d30ed63f 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -44,7 +44,6 @@ my %opts = (
         Listen => 1024,
 );
 my $sock = IO::Socket::INET->new(%opts);
-plan skip_all => 'sock fd!=3, cannot test nntpd integration' if fileno($sock) != 3;
 my $pid;
 END { kill 'TERM', $pid if defined $pid };
 {
@@ -78,8 +77,10 @@ EOF
         is($fl, FD_CLOEXEC, 'cloexec set by default (Perl behavior)');
         $pid = fork;
         if ($pid == 0) {
+                use POSIX qw(dup2);
                 # pretend to be systemd
                 fcntl($sock, F_SETFD, $fl &= ~FD_CLOEXEC);
+                dup2(fileno($sock), 3) or die "dup2 failed: $!\n";
                 $ENV{LISTEN_PID} = $$;
                 $ENV{LISTEN_FDS} = 1;
                 exec $nntpd, "--stdout=$out", "--stderr=$err";