about summary refs log tree commit homepage
path: root/test/test_bin.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2013-10-21 04:07:21 +0000
committerEric Wong <e@80x24.org>2013-10-21 04:09:25 +0000
commitfbed65999dc8e1dd4b21a2b54a3ad3afcc5b0849 (patch)
tree3160f46c53ec8e830634b77e3c8b8468f270622a /test/test_bin.rb
parent3a9330dfcc187e4e7f32ede08d1fed416a568d71 (diff)
downloadyahns-fbed65999dc8e1dd4b21a2b54a3ad3afcc5b0849.tar.gz
Diffstat (limited to 'test/test_bin.rb')
-rw-r--r--test/test_bin.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/test/test_bin.rb b/test/test_bin.rb
index f6d11b2..610c99d 100644
--- a/test/test_bin.rb
+++ b/test/test_bin.rb
@@ -42,10 +42,13 @@ class TestBin < Testcase
     @cmd.concat(%W(-D -c #{cfg.path}))
     addr = IO.pipe
     pid = fork do
+      addr[0].close
       if inherit
         @cmd << { @srv.fileno => @srv }
         ENV["YAHNS_FD"] = @srv.fileno.to_s
       else
+        # we must create the socket inside the child and tell the parent
+        # about it to avoid sharing
         @srv = TCPServer.new(ENV["TEST_HOST"] || "127.0.0.1", 0)
         @srv.close_on_exec = true # needed for 1.9.3
       end
@@ -53,7 +56,6 @@ class TestBin < Testcase
       listen = ENV["YAHNS_TEST_LISTEN"] = "#{host}:#{port}"
       addr[1].write(listen)
       addr[1].close
-      addr[0].close
       exec(*@cmd)
     end
     addr[1].close