Bug #166 [ruby-core:17270]
Signal handling and sleep() don't work together
| Status : | Closed | Start : | 06/16/2008 | |
| Priority : | Normal | Due date : | ||
| Assigned to : | - | % Done : | 100% |
|
| Category : | - | |||
| Target version : | - | |||
| ruby -v : |
Description
Setting up a sleep seems to interfere with signal handlers. The following code
trap("CLD") do
pid = Process.wait
puts "Child pid #{pid}: terminated"
end
exec("/bin/sh -c 'echo hello'") if fork.nil?
puts "start"
sleep 2
puts "done"
Outputs start/hello/done with no delay, and the trap never fires. Replace the sleep with a gets, and the signal handler gets invoked—it never writes “Child xxx terminated.”
Associated revisions
- thread_{pthread,win32}.c (native_sleep): wait until timed out.
[ruby-core:17270]
- thread.c (sleep_forever): wait until timed out.
[ruby-core:17270]
- thread.c (thread_start_func_2): wake up joining threads.
- thread.c (sleep_forever, sleep_timeval): return when interrupted.
[ruby-dev:35542] - thread.c (timer_thread_function): restore main thread status.
[ruby-core:17270]