1 # depends on: module.rb
9 def self.trap(sig, prc=nil, pass_ctx=false, &block)
10 sig = sig.to_s if sig.kind_of?(Symbol)
12 if sig.kind_of?(String)
20 at_exit { block.call }
24 unless number = Names[sig]
25 raise ArgumentError, "Unknown signal '#{osig}'"
32 raise ArgumentError, "Either a Proc or a block, not both."
37 old = @handlers[number]
39 @handlers[number] = prc
41 # If there is already at thread for this sig, give up.
42 return old if @threads[number]
50 # Run the handler in a new thread so chan.receive doesn't
51 # block signals during handler execution, e.g., a SIGINT
52 # during a sleep() in a SIGINT handler.
62 @handlers[number].call(obj)
70 @threads[number] = thr
72 Scheduler.send_on_signal chan, number
76 def self.action(sig, prc=nil, &block)
77 trap(sig, prc, true, &block)
85 Rubinius::RUBY_CONFIG.keys.each do |key|
86 if key[0, 20] == 'rbx.platform.signal.'
87 Names[ key[23, 100] ] = Rubinius::RUBY_CONFIG[key]
90 # special case of signal.c
92 Names["CLD"] = Names["CHLD"]