about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--test/inherit.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/inherit.rb b/test/inherit.rb
index d9da78d..07efd3c 100644
--- a/test/inherit.rb
+++ b/test/inherit.rb
@@ -14,6 +14,8 @@ class TestInherit < Test::Unit::TestCase
     @to_close << @srv
     @port = @srv.addr[1]
     @err = Tempfile.new("stderr")
+    @pid = nil
+    @exec_fds = {}
   end
 
   # Ruby 1.8 did not have the close_on_exec= method, but it
@@ -21,7 +23,16 @@ class TestInherit < Test::Unit::TestCase
   # 2.0.0 will be the first release with close_on_exec=true
   # by default, but 1.9 already added the close_on_exec= method
   def maybe_cloexec(io, val)
-     io.close_on_exec = val if io.respond_to?(:close_on_exec=)
+    if io.respond_to?(:close_on_exec=)
+      io.close_on_exec = val
+      @exec_fds[io.fileno] = io
+    end
+  end
+
+  # FD inheritance is explicit in Ruby 2.0.0
+  def exec(*cmd)
+    cmd << @exec_fds if @exec_fds.size > 0
+    Process.exec(*cmd)
   end
 
   def teardown