Skip to content

Commit

Permalink
Fix trap(:EXIT) specs
Browse files Browse the repository at this point in the history
This combined with the addition of rb_thread_writable_fd and
UNIXSocket#recv_io / send_io fixes issue rubinius#632
  • Loading branch information
dbussink committed Jan 5, 2011
1 parent acb38e7 commit ef2015e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
19 changes: 7 additions & 12 deletions kernel/common/signal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,11 @@ def self.trap(sig, prc=nil, &block)
sig = sig[3..-1]
end

if sig == "EXIT"
at_exit(&block)
return
end

unless number = Names[sig]
raise ArgumentError, "Unknown signal '#{osig}'"
end
else
number = sig.to_i

if number == 0
at_exit(&block)
return
end
end

# If no command, use the block.
Expand All @@ -38,7 +28,10 @@ def self.trap(sig, prc=nil, &block)
when "DEFAULT", "SIG_DFL"
had_old = @handlers.key?(number)
old = @handlers.delete(number)
Rubinius.watch_signal -number

if number != Names["EXIT"]
Rubinius.watch_signal -number
end

return "DEFAULT" unless had_old
return old ? old : "IGNORE"
Expand All @@ -59,7 +52,9 @@ def self.trap(sig, prc=nil, &block)
old = @handlers[number]
@handlers[number] = prc

Rubinius.watch_signal number
if number != Names["EXIT"]
Rubinius.watch_signal number
end

return "DEFAULT" unless had_old
return old ? old : "IGNORE"
Expand Down
6 changes: 6 additions & 0 deletions kernel/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,12 @@ def irb
def epilogue
@stage = "at_exit handler"

begin
Signal.run_handler(Signal::Names["EXIT"])
rescue SystemExit => e
@exit_code = e.status
end

until AtExit.empty?
begin
AtExit.shift.call
Expand Down

0 comments on commit ef2015e

Please sign in to comment.