diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-05-20 19:50:34 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-05-20 19:51:16 -0700 |
commit | a5357ad014d2eacc99dd7ee46040686cbf1d871c (patch) | |
tree | 9c12f874840edb6f34ac45fc5e97562c6b7c68dd /test | |
parent | 605765ded31c784727077dfca573092ba725f717 (diff) | |
download | kgio-a5357ad014d2eacc99dd7ee46040686cbf1d871c.tar.gz |
Retry on a zero timeout if we get interrupted even if the timeout expired. This is also what IO.select does in Ruby itself.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_poll.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/test_poll.rb b/test/test_poll.rb index d99e5aa..32d0a4d 100644 --- a/test/test_poll.rb +++ b/test/test_poll.rb @@ -90,4 +90,31 @@ class TestPoll < Test::Unit::TestCase ensure trap(:USR1, orig) end + + def test_poll_signal_torture + usr1 = 0 + empty = 0 + nr = 100 + set = { @rd => Kgio::POLLIN } + trap(:USR1) { usr1 += 1 } + pid = fork do + trap(:USR1, "DEFAULT") + sleep 0.1 + ppid = Process.ppid + nr.times { Process.kill(:USR1, ppid); sleep 0.05 } + @wr.syswrite('.') + exit!(0) + end + + assert_nothing_raised do + empty += 1 until Kgio.poll(set.dup, 100) + end + _, status = Process.waitpid2(pid) + assert status.success?, status.inspect + assert usr1 > 0, "usr1: #{usr1}" + rescue Object => err + p [ :err, err ] + ensure + trap(:USR1, "DEFAULT") + end end if Kgio.respond_to?(:poll) |