]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/httpd-corner: avoid clobbering existing FDs after fork
authorEric Wong <e@80x24.org>
Sat, 5 Mar 2016 07:35:22 +0000 (07:35 +0000)
committerEric Wong <e@80x24.org>
Sat, 5 Mar 2016 07:35:22 +0000 (07:35 +0000)
Due to the deterministic way reference counting works,
we do not want to drop references to existing FDs
even if we no longer need the glob reference; the actual
FD is all we can pass through on exec.

t/httpd-corner.t

index a6238e4871f09ed4658d4c317de9b05c3f5faf88..833eb4294687361c06c38277e6bf3d7c98dc9ae9 100644 (file)
@@ -55,10 +55,10 @@ my $spawn_httpd = sub {
                # pretend to be systemd
                dup2(fileno($sock), 3) or die "dup2 failed: $!\n";
                dup2(fileno($unix), 4) or die "dup2 failed: $!\n";
-               $sock = IO::Handle->new_from_fd(3, 'r');
-               $sock->fcntl(F_SETFD, 0);
-               $unix = IO::Handle->new_from_fd(4, 'r');
-               $unix->fcntl(F_SETFD, 0);
+               my $t = IO::Handle->new_from_fd(3, 'r');
+               $t->fcntl(F_SETFD, 0);
+               my $u = IO::Handle->new_from_fd(4, 'r');
+               $u->fcntl(F_SETFD, 0);
                $ENV{LISTEN_PID} = $$;
                $ENV{LISTEN_FDS} = 2;
                exec $httpd, @args, "--stdout=$out", "--stderr=$err", $psgi;