From: "kosaki (Motohiro KOSAKI)" Date: 2012-11-06T02:31:18+09:00 Subject: [ruby-core:48947] [ruby-trunk - Bug #7134] Signal handling bug in Mac OS X Issue #7134 has been updated by kosaki (Motohiro KOSAKI). Note: current documentation of Process.kill() uses puts() in trap handler. So, I personally don't think that IO in trap handler is invalid code. /* * call-seq: * Process.kill(signal, pid, ...) -> fixnum * * Sends the given signal to the specified process id(s) if _pid_ is positive. * If _pid_ is zero _signal_ is sent to all processes whose group ID is equal * to the group ID of the process. _signal_ may be an integer signal number or * a POSIX signal name (either with or without a +SIG+ prefix). If _signal_ is * negative (or starts with a minus sign), kills process groups instead of * processes. Not all signals are available on all platforms. * * pid = fork do * Signal.trap("HUP") { puts "Ouch!"; exit } * # ... do some work ... * end * # ... * Process.kill("HUP", pid) * Process.wait ---------------------------------------- Bug #7134: Signal handling bug in Mac OS X https://bugs.ruby-lang.org/issues/7134#change-32451 Author: auastro (Andy Kitchen) Status: Assigned Priority: Normal Assignee: nobu (Nobuyoshi Nakada) Category: Target version: next minor ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12] On Mac OS X, running the attached program causes the exception below about 1/10 times it is run. $ ruby hup.rb hup.rb:2:in `write': deadlock; recursive locking (ThreadError) from hup.rb:2:in `puts' from hup.rb:2:in `puts' from hup.rb:2:in `block in
' from hup.rb:6:in `call' from hup.rb:6:in `write' from hup.rb:6:in `puts' from hup.rb:6:in `puts' from hup.rb:6:in `
' The expected output is: > In Hup Handler >Finished... or > Finished... > In Hup Handler My ruby is compiled with clang: $ clang --version Apple clang version 4.1 (tags/Apple/clang-421.11.65) (based on LLVM 3.1svn) Target: x86_64-apple-darwin12.2.0 Thread model: posix -- http://bugs.ruby-lang.org/