diff options
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_io.rb | 25 | ||||
-rw-r--r-- | test/ruby/test_process.rb | 7 |
2 files changed, 32 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index c2eecb7397..e4af5e0e9f 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2030,4 +2030,29 @@ End end assert_equal("[Feature #5029]\n[ruby-core:38070]\n", stderr) end + + def test_cloexec + return unless defined? Fcntl::FD_CLOEXEC + open(__FILE__) {|f| + assert(f.close_on_exec?) + g = f.dup + begin + assert(g.close_on_exec?) + f.reopen(g) + assert(f.close_on_exec?) + ensure + g.close + end + g = IO.new(f.fcntl(Fcntl::F_DUPFD)) + begin + assert(g.close_on_exec?) + ensure + g.close + end + } + IO.pipe {|r,w| + assert(r.close_on_exec?) + assert(w.close_on_exec?) + } + end end diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 5c05a47af5..a731dee99d 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1323,4 +1323,11 @@ class TestProcess < Test::Unit::TestCase end end end + + def test_popen_cloexec + return unless defined? Fcntl::FD_CLOEXEC + IO.popen([RUBY, "-e", ""]) {|io| + assert(io.close_on_exec?) + } + end end |