summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-16 23:56:08 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-16 23:56:08 +0000
commitb53fadfd5f200dbd6fe9f4b2a91ebb68618e59bb (patch)
tree460743a4634657cb7161c682a6e05b248e7a8d37 /test
parent2cf3bd5bb2a7c4724e528577d37a883fe80a1122 (diff)
process.c: defaults to close_others false
Arbitrarily closing file descriptors on exec breaks use cases where a Ruby process sets up a descriptor for non-Ruby children to use. For example, the "rake foo" target may spawn any number of subprocesses (Ruby or not) which depends on parsing the "FOO" environment variable for out_fd:99 and writing to foo.out FOO=out_fd:99 rake foo 99>>foo.out Unfortunately, this introduced one incompatibility in test/lib/test/unit.rb and it now requires explicitly setting IO#close_on_exec=true [ruby-core:88007] [Misc #14907] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/lib/test/unit.rb2
-rw-r--r--test/ruby/test_process.rb9
2 files changed, 11 insertions, 0 deletions
diff --git a/test/lib/test/unit.rb b/test/lib/test/unit.rb
index 51c8960c52..7a09466d1c 100644
--- a/test/lib/test/unit.rb
+++ b/test/lib/test/unit.rb
@@ -145,6 +145,8 @@ module Test
r.close if r
nil
else
+ r.close_on_exec = true
+ w.close_on_exec = true
@jobserver = [r, w]
options[:parallel] ||= 1
end
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index a0b08dd110..bb56834dc0 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -1009,6 +1009,15 @@ class TestProcess < Test::Unit::TestCase
}
end
+ def test_close_others_default_false
+ IO.pipe do |r,w|
+ w.close_on_exec = false
+ src = "IO.new(#{w.fileno}).puts(:hi)"
+ assert_equal true, system(*%W(#{RUBY} --disable=gems -e #{src}))
+ assert_equal "hi\n", r.gets
+ end
+ end
+
def test_execopts_redirect_self
begin
with_pipe {|r, w|