about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/yahns/sigevent_pipe.rb1
-rw-r--r--test/helper.rb4
-rw-r--r--test/test_bin.rb2
-rw-r--r--test/test_output_buffering.rb4
-rw-r--r--test/test_server.rb2
-rw-r--r--test/test_wbuf.rb6
6 files changed, 12 insertions, 7 deletions
diff --git a/lib/yahns/sigevent_pipe.rb b/lib/yahns/sigevent_pipe.rb
index 6e1be53..8bd083f 100644
--- a/lib/yahns/sigevent_pipe.rb
+++ b/lib/yahns/sigevent_pipe.rb
@@ -5,6 +5,7 @@ class Yahns::Sigevent # :nodoc:
   attr_reader :to_io
   def initialize
     @to_io, @wr = Kgio::Pipe.new
+    @to_io.close_on_exec = @wr.close_on_exec = true
   end
 
   def kgio_wait_readable
diff --git a/test/helper.rb b/test/helper.rb
index 730b96c..3f141e4 100644
--- a/test/helper.rb
+++ b/test/helper.rb
@@ -114,6 +114,10 @@ class IO
   end
 end if ! IO.method_defined?(:nread) && RUBY_PLATFORM =~ /linux/
 
+def cloexec_pipe
+  IO.pipe.each { |io| io.close_on_exec = true }
+end
+
 require 'yahns'
 
 # needed for parallel (MT) tests)
diff --git a/test/test_bin.rb b/test/test_bin.rb
index 71333e7..8944eb3 100644
--- a/test/test_bin.rb
+++ b/test/test_bin.rb
@@ -40,7 +40,7 @@ class TestBin < Testcase
     cfg.puts "  listen ENV['YAHNS_TEST_LISTEN']"
     cfg.puts "end"
     @cmd.concat(%W(-D -c #{cfg.path}))
-    addr = IO.pipe
+    addr = cloexec_pipe
     pid = fork do
       opts = { close_others: true }
       addr[0].close
diff --git a/test/test_output_buffering.rb b/test/test_output_buffering.rb
index afb23f8..ae9b449 100644
--- a/test/test_output_buffering.rb
+++ b/test/test_output_buffering.rb
@@ -77,8 +77,8 @@ class TestOutputBuffering < Testcase
       # HTTP/0.9
       c = get_tcp_client(host, port)
       c.write("GET /\r\n\r\n")
-      md5in = IO.pipe
-      md5out = IO.pipe
+      md5in = cloexec_pipe
+      md5out = cloexec_pipe
       sleep(delay) if delay
       md5pid = Process.spawn("md5sum", :in => md5in[0], :out => md5out[1])
       md5in[0].close
diff --git a/test/test_server.rb b/test/test_server.rb
index c277896..d87f617 100644
--- a/test/test_server.rb
+++ b/test/test_server.rb
@@ -193,7 +193,7 @@ class TestServer < Testcase
     msgs = %w(ZZ zz)
     err = @err
     cfg = Yahns::Config.new
-    bpipe = IO.pipe
+    bpipe = cloexec_pipe
     host, port = @srv.addr[3], @srv.addr[1]
     cfg.instance_eval do
       ru = lambda { |e|
diff --git a/test/test_wbuf.rb b/test/test_wbuf.rb
index 0923eb0..44ac74e 100644
--- a/test/test_wbuf.rb
+++ b/test/test_wbuf.rb
@@ -16,7 +16,7 @@ class TestWbuf < Testcase
       assert_equal "HIHI", b.read(4)
       nr.times { wbuf.wbuf_write(a, buf) }
       assert_equal :wait_writable, wbuf.wbuf_flush(a)
-      done = IO.pipe
+      done = cloexec_pipe
       thr = Thread.new do
         rv = []
         until rv[-1] == persist
@@ -86,7 +86,7 @@ class TestWbuf < Testcase
   end
 
   def test_wbuf_flush_close
-    pipe = IO.pipe
+    pipe = cloexec_pipe
     persist = true
     wbuf = Yahns::Wbuf.new(pipe[0], persist)
     refute wbuf.respond_to?(:close) # we don't want this for HttpResponse body
@@ -103,7 +103,7 @@ class TestWbuf < Testcase
     assert_equal thr, thr.join(5)
     assert_equal :wait_writable, rv
 
-    done = IO.pipe
+    done = cloexec_pipe
     thr = Thread.new do
       rv = []
       until rv[-1] == persist