diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-22 09:58:15 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-22 09:58:15 +0000 |
commit | b574a4d4a1f1d77fa0224b02774456107cdbc932 (patch) | |
tree | 000945919a3486eb709a026a09688017e73b2ce8 /test | |
parent | 00715f4c5aa12eec0dd88fb08bc7f46d23de8d40 (diff) | |
download | ruby-b574a4d4a1f1d77fa0224b02774456107cdbc932.tar.gz |
* include/ruby/intern.h (rb_fd_set_cloexec): declared.
* io.c (rb_fd_set_cloexec): new function.
(ruby_dup): call rb_fd_set_cloexec to set close-on-exec flag.
(rb_sysopen_internal): ditto.
(rb_pipe): ditto.
(io_reopen): ditto.
(io_cntl): ditto.
* process.c (rb_f_exec): change the default :close_others option to
true.
(rb_f_system): ditto.
(move_fds_to_avoid_crash): call rb_fd_set_cloexec to set
close-on-exec flag.
(ruby_setsid): ditto.
(rb_daemon): ditto.
* thread_pthread.c (rb_thread_create_timer_thread): call
rb_fd_set_cloexec to set close-on-exec flag.
* ruby.c (load_file_internal): ditto.
* file.c (rb_file_s_truncate): ditto.
(file_load_ok): ditto.
* random.c (fill_random_seed): ditto.
* ext/pty/pty.c (chfunc): ditto.
(get_device_once): ditto.
* ext/openssl/ossl_bio.c (ossl_obj2bio): ditto.
* ext/socket/init.c (rsock_socket): ditto.
(rsock_s_accept_nonblock): ditto.
(rsock_s_accept): ditto.
* ext/socket/socket.c (rsock_sock_s_socketpair): ditto.
* ext/socket/ancdata.c (discard_cmsg): ditto.
(make_io_for_unix_rights): ditto.
* ext/socket/unixsocket.c (unix_recv_io): ditto.
* ext/io/console/console.c (console_dev): ditto.
[ruby-core:38140] [Feature #5041]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_io.rb | 6 | ||||
-rw-r--r-- | test/ruby/test_process.rb | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index d4787c75b4..e3bbd245ed 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1261,6 +1261,8 @@ class TestIO < Test::Unit::TestCase def test_close_on_exec skip "IO\#close_on_exec is not implemented." unless have_close_on_exec? ruby do |f| + assert_equal(true, f.close_on_exec?) + f.close_on_exec = false assert_equal(false, f.close_on_exec?) f.close_on_exec = true assert_equal(true, f.close_on_exec?) @@ -1269,12 +1271,16 @@ class TestIO < Test::Unit::TestCase end with_pipe do |r, w| + assert_equal(true, r.close_on_exec?) + r.close_on_exec = false assert_equal(false, r.close_on_exec?) r.close_on_exec = true assert_equal(true, r.close_on_exec?) r.close_on_exec = false assert_equal(false, r.close_on_exec?) + assert_equal(true, w.close_on_exec?) + w.close_on_exec = false assert_equal(false, w.close_on_exec?) w.close_on_exec = true assert_equal(true, w.close_on_exec?) diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index c68b6008fe..5c05a47af5 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -603,7 +603,7 @@ class TestProcess < Test::Unit::TestCase def test_fd_inheritance skip "inheritance of fd other than stdin,stdout and stderr is not supported" if windows? with_pipe {|r, w| - system(RUBY, '-e', 'IO.new(ARGV[0].to_i, "w").puts(:ba)', w.fileno.to_s) + system(RUBY, '-e', 'IO.new(ARGV[0].to_i, "w").puts(:ba)', w.fileno.to_s, w=>w) w.close assert_equal("ba\n", r.read) } @@ -619,8 +619,9 @@ class TestProcess < Test::Unit::TestCase write_file("s", <<-"End") exec(#{RUBY.dump}, '-e', 'IO.new(ARGV[0].to_i, "w").puts("bu") rescue nil', - #{w.fileno.to_s.dump}) + #{w.fileno.to_s.dump}, :close_others=>false) End + w.close_on_exec = false Process.wait spawn(RUBY, "s", :close_others=>false) w.close assert_equal("bu\n", r.read) @@ -660,6 +661,7 @@ class TestProcess < Test::Unit::TestCase File.unlink("err") } with_pipe {|r, w| + w.close_on_exec = false Process.wait spawn(RUBY, '-e', 'IO.new(ARGV[0].to_i, "w").puts("bi")', w.fileno.to_s, :close_others=>false) w.close assert_equal("bi\n", r.read) @@ -686,6 +688,7 @@ class TestProcess < Test::Unit::TestCase Process.wait } with_pipe {|r, w| + w.close_on_exec = false io = IO.popen([RUBY, "-e", "STDERR.reopen(STDOUT); IO.new(#{w.fileno}, 'w').puts('mo')", :close_others=>false]) w.close errmsg = io.read @@ -694,6 +697,7 @@ class TestProcess < Test::Unit::TestCase Process.wait } with_pipe {|r, w| + w.close_on_exec = false io = IO.popen([RUBY, "-e", "STDERR.reopen(STDOUT); IO.new(#{w.fileno}, 'w').puts('mo')", :close_others=>nil]) w.close errmsg = io.read |