about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-04-26 20:02:11 +0000
committerEric Wong <normalperson@yhbt.net>2013-04-29 21:01:01 +0000
commit6b631c291e7220daad2954a129153de774a76572 (patch)
tree4a18de7a7130ff4aecbeeddd43652ae97d4f5805
parentd1b31d49b2c376ce3c7691b5037d5edea517fb09 (diff)
downloadsleepy_penguin-6b631c291e7220daad2954a129153de774a76572.tar.gz
It's generally unsafe to sleep inside a signal handler, and
seems to cause intermittent test failures.
-rw-r--r--test/test_epoll.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/test_epoll.rb b/test/test_epoll.rb
index 163a32c..c6cc198 100644
--- a/test/test_epoll.rb
+++ b/test/test_epoll.rb
@@ -154,10 +154,13 @@ class TestEpoll < Test::Unit::TestCase
 
   def test_signal_safe_wait_forever
     time = {}
+    thr = nil
     trap(:USR1) do
       time[:USR1] = Time.now
-      sleep 0.5
-      @wr.write '.'
+      thr = Thread.new do
+        sleep 0.5
+        @wr.syswrite '.'
+      end
     end
     @ep.add @rd, Epoll::IN
     tmp = []
@@ -178,6 +181,8 @@ class TestEpoll < Test::Unit::TestCase
     assert_in_delta(0.5, usr1_delay, 0.1, "usr1_delay=#{usr1_delay}")
     ep_delay = time[:EP] - time[:USR1]
     assert_in_delta(0.5, ep_delay, 0.1, "ep1_delay=#{ep_delay}")
+    assert_kind_of Thread, thr
+    thr.join
     ensure
       trap(:USR1, 'DEFAULT')
   end