Bug #166 [ruby-core:17270]

Signal handling and sleep() don't work together

Added by Dave Thomas 168 days ago. Updated 145 days ago.

Status :Closed Start :06/16/2008
Priority :Normal Due date :
Assigned to :- % Done :

100%

Category :-
Target version :-

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 145 days ago

Revision 17976
Added by nobu 145 days ago

Revision 18094
Added by nobu 138 days 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

07/09/2008 08:37 PM - Nobuyoshi Nakada

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

Also available in: Atom PDF