Bug #166

Signal handling and sleep() don't work together

Added by pragdave (Dave Thomas) almost 4 years ago. Updated about 1 year ago.

[ruby-core:17270]
Status:Closed Start date:06/16/2008
Priority:Normal Due date:
Assignee:- % 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

Revision 17973
Added by nobu (Nobuyoshi Nakada) almost 4 years ago

* thread_{pthread,win32}.c (native_sleep): wait until timed out. [ruby-core:17270]

Revision 17976
Added by nobu (Nobuyoshi Nakada) almost 4 years ago

* thread.c (sleep_forever): wait until timed out. [ruby-core:17270]

Revision 18094
Added by nobu (Nobuyoshi Nakada) almost 4 years ago

* 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]

History

Updated by nobu (Nobuyoshi Nakada) almost 4 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
Applied in changeset r17973.

Also available in: Atom PDF