aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-09 15:02:46 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-09 15:02:46 +0000
commit87f025da25e2ce7f75f99cc71bd5396ecbf4ae1c (patch)
tree275d6c78369796c14d4917b41557395f92f27186 /test/ruby
parent1fdbe0f437de59f87527818918b55d794a5fb92d (diff)
downloadruby-87f025da25e2ce7f75f99cc71bd5396ecbf4ae1c.tar.gz
* io.c: fix IO.copy_stream interrupt handling.
based on the patch by Eric Wong. [ruby-core:36156] * vm_core.h (rb_thread_call_with_gvl): don't declare here. * thread.c: include internal.h. (rb_thread_execute_interrupts): new function. * internal.h (rb_thread_execute_interrupts): declared. (rb_thread_call_with_gvl): declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_io.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index de78b71c6a..0a100b1457 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -78,6 +78,14 @@ class TestIO < Test::Unit::TestCase
}
end
+ def trapping_usr1
+ @usr1_rcvd = 0
+ trap(:USR1) { @usr1_rcvd += 1 }
+ yield
+ ensure
+ trap(:USR1, "DEFAULT")
+ end
+
def test_pipe
r, w = IO.pipe
assert_instance_of(IO, r)
@@ -594,6 +602,30 @@ class TestIO < Test::Unit::TestCase
result = t.value
assert_equal(megacontent, result)
}
+ with_socketpair {|s1, s2|
+ begin
+ s1.nonblock = true
+ rescue Errno::EBADF
+ skip "nonblocking IO for pipe is not implemented"
+ end
+ trapping_usr1 do
+ nr = 10
+ pid = fork do
+ s1.close
+ IO.select([s2])
+ Process.kill(:USR1, Process.ppid)
+ s2.read
+ end
+ s2.close
+ nr.times do
+ assert_equal megacontent.bytesize, IO.copy_stream("megasrc", s1)
+ end
+ assert_equal(1, @usr1_rcvd)
+ s1.close
+ _, status = Process.waitpid2(pid)
+ assert status.success?, status.inspect
+ end
+ }
end
}
end