diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-04-29 19:36:40 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-04-29 21:01:02 +0000 |
commit | c04b173f52c362c64899bd7b2942cab0658e1cee (patch) | |
tree | 891a925e450f873af6a46cafbbf857a96ffa4c44 | |
parent | 98af77f834ca0a821a091085a3fdc5e645f704fc (diff) | |
download | sleepy_penguin-c04b173f52c362c64899bd7b2942cab0658e1cee.tar.gz |
Threads do not seem safe to start inside signal handlers on Matz Ruby 1.8
-rw-r--r-- | test/test_epoll.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/test/test_epoll.rb b/test/test_epoll.rb index c6cc198..5bf332f 100644 --- a/test/test_epoll.rb +++ b/test/test_epoll.rb @@ -153,14 +153,17 @@ class TestEpoll < Test::Unit::TestCase end def test_signal_safe_wait_forever + sigpipe = IO.pipe time = {} - thr = nil + thr = Thread.new do + IO.select([sigpipe[0]]) # wait for USR1 + sigpipe[0].read(1) + sleep 0.5 + @wr.syswrite '.' + end trap(:USR1) do time[:USR1] = Time.now - thr = Thread.new do - sleep 0.5 - @wr.syswrite '.' - end + sigpipe[1].syswrite('.') # wake up thr end @ep.add @rd, Epoll::IN tmp = [] @@ -184,6 +187,7 @@ class TestEpoll < Test::Unit::TestCase assert_kind_of Thread, thr thr.join ensure + sigpipe.each { |io| io.close } trap(:USR1, 'DEFAULT') end |