From be3672501ecde716dae723e887d4a9e4d731240c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 16 Nov 2011 18:37:37 -0800 Subject: connect,tryopen: set close-on-exec flag for new fds on Ruby 2.0+ All IO objects created by Kgio will have FD_CLOEXEC descriptor flag set on it when run under Ruby 2.0.0dev. This matches the upcoming behavior of Ruby 2.0.0dev for IO objects in the core and standard library. This change does not affect users on Ruby 1.9.3 and earlier. accept()-ed sockets in kgio have _always_ had FD_CLOEXEC set by default. --- test/test_unix_connect.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/test_unix_connect.rb') diff --git a/test/test_unix_connect.rb b/test/test_unix_connect.rb index f99a877..b85f1f6 100644 --- a/test/test_unix_connect.rb +++ b/test/test_unix_connect.rb @@ -34,6 +34,10 @@ class TestKgioUnixConnect < Test::Unit::TestCase def test_unix_socket_new sock = Kgio::UNIXSocket.new(@path) + + sock.respond_to?(:close_on_exec?) and + assert_equal(RUBY_VERSION.to_f >= 2.0, sock.close_on_exec?) + assert_instance_of Kgio::UNIXSocket, sock ready = IO.select(nil, [ sock ]) assert_equal sock, ready[1][0] @@ -42,6 +46,10 @@ class TestKgioUnixConnect < Test::Unit::TestCase def test_new sock = Kgio::Socket.new(@addr) + + sock.respond_to?(:close_on_exec?) and + assert_equal(RUBY_VERSION.to_f >= 2.0, sock.close_on_exec?) + assert_instance_of Kgio::Socket, sock ready = IO.select(nil, [ sock ]) assert_equal sock, ready[1][0] -- cgit v1.2.3-24-ge0c7