diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-03 11:15:15 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-03 11:15:15 +0000 |
commit | 88f1b8cf0c286d5a499d0832cde5ff6be4105d89 (patch) | |
tree | de55d3ce3930d527ccd672ed2cb58b92567dd3d0 /test/ruby | |
parent | df6a0fe8bb0d41634689af8dcbee2c3e5eed4818 (diff) |
add test for close-on-exec.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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 |