From: "nagachika (Tomoyuki Chikanaga)" Date: 2013-02-25T02:53:15+09:00 Subject: [ruby-core:52841] [ruby-trunk - Feature #7918] Create Signal.in_trap?() Issue #7918 has been updated by nagachika (Tomoyuki Chikanaga). Hello, This feature looks reasonable for me. I'd like to clarify the specification. Should the following code show true? or false? Signal.trap(:USR1) do Process.kill(:USR2, $$) end Signal.trap(:USR2) do p Process.in_trap?(:USR2) # => true p Process.in_trap?(:USR1) # => true or false? end Process.kill(:USR1, $$) sleep ---------------------------------------- Feature #7918: Create Signal.in_trap?() https://bugs.ruby-lang.org/issues/7918#change-36950 Author: kosaki (Motohiro KOSAKI) Status: Open Priority: Normal Assignee: Category: core Target version: 2.1.0 Currently, ruby library have no way to detect a method is called from trap handler or not. This is useful because Mutex#lock under trap raises an exception and some libraries may want to avoid it. Then, I would like to create Signal.in_trap?() class method. Signal.in_trap?(signal = nil) return true when running trap handler. return false otherwise. When signal argument is specified, return true only when running trap of specified signal. Thought? -- http://bugs.ruby-lang.org/