-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Spec 'Signal.trap ignores the signal when passed nil' OK for rx19:
- extract Signal.trap from kernel/common/signal.rb to kernel/common/signal18.rb; - create a new file kernel/common/signal19.rb with new version for Signal.trap: - in case stattement, add a new +when nil+ statetement which set +prc+ to +nil+; - in +when "IGNORE", "SIG_IGN"+ statement, +prc+ is set to "IGNORE" string; - in Rubinius.watch_signal, replace +prc.nil?+ with +prc.nil? || prc == 'IGNORE'+; - return statements now return +nil+ when +old+ is false instead of "IGNORE"; - modify kernel/common/load_order*.
- Loading branch information
Showing
6 changed files
with
127 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ random.rbc | |
regexp.rbc | ||
regexp18.rbc | ||
signal.rbc | ||
signal18.rbc | ||
splitter.rbc | ||
splitter18.rbc | ||
sprinter.rbc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# -*- encoding: us-ascii -*- | ||
|
||
module Signal | ||
|
||
def self.trap(sig, prc=nil, &block) | ||
sig = sig.to_s if sig.kind_of?(Symbol) | ||
|
||
if sig.kind_of?(String) | ||
osig = sig | ||
|
||
if sig.prefix? "SIG" | ||
sig = sig[3..-1] | ||
end | ||
|
||
unless number = Names[sig] | ||
raise ArgumentError, "Unknown signal '#{osig}'" | ||
end | ||
else | ||
number = sig.to_i | ||
end | ||
|
||
# If no command, use the block. | ||
prc ||= block | ||
|
||
case prc | ||
when "DEFAULT", "SIG_DFL" | ||
had_old = @handlers.key?(number) | ||
old = @handlers.delete(number) | ||
|
||
if number != Names["EXIT"] | ||
Rubinius.watch_signal(-number, prc.nil?) | ||
end | ||
|
||
return "DEFAULT" unless had_old | ||
return old ? old : "IGNORE" | ||
when "IGNORE", "SIG_IGN", nil | ||
prc = nil | ||
when "EXIT" | ||
prc = proc { exit } | ||
when String | ||
raise ArgumentError, "Unsupported command '#{prc}'" | ||
else | ||
unless prc.respond_to? :call | ||
raise ArgumentError, "Handler must respond to #call (was #{prc.class})" | ||
end | ||
end | ||
|
||
had_old = @handlers.key?(number) | ||
|
||
old = @handlers[number] | ||
@handlers[number] = prc | ||
|
||
if number != Names["EXIT"] | ||
Rubinius.watch_signal(number, prc.nil?) | ||
end | ||
|
||
return "DEFAULT" unless had_old | ||
return old ? old : "IGNORE" | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# -*- encoding: us-ascii -*- | ||
|
||
module Signal | ||
|
||
def self.trap(sig, prc=nil, &block) | ||
sig = sig.to_s if sig.kind_of?(Symbol) | ||
|
||
if sig.kind_of?(String) | ||
osig = sig | ||
|
||
if sig.prefix? "SIG" | ||
sig = sig[3..-1] | ||
end | ||
|
||
unless number = Names[sig] | ||
raise ArgumentError, "Unknown signal '#{osig}'" | ||
end | ||
else | ||
number = sig.to_i | ||
end | ||
|
||
# If no command, use the block. | ||
prc ||= block | ||
|
||
case prc | ||
when "DEFAULT", "SIG_DFL" | ||
had_old = @handlers.key?(number) | ||
old = @handlers.delete(number) | ||
|
||
if number != Names["EXIT"] | ||
Rubinius.watch_signal(-number, prc.nil?) | ||
end | ||
|
||
return "DEFAULT" unless had_old | ||
return old ? old : nil | ||
when "IGNORE", "SIG_IGN" | ||
prc = "IGNORE" | ||
when nil | ||
prc = nil | ||
when "EXIT" | ||
prc = proc { exit } | ||
when String | ||
raise ArgumentError, "Unsupported command '#{prc}'" | ||
else | ||
unless prc.respond_to? :call | ||
raise ArgumentError, "Handler must respond to #call (was #{prc.class})" | ||
end | ||
end | ||
|
||
had_old = @handlers.key?(number) | ||
|
||
old = @handlers[number] | ||
@handlers[number] = prc | ||
|
||
if number != Names["EXIT"] | ||
Rubinius.watch_signal(number, prc.nil? || prc == 'IGNORE') | ||
end | ||
|
||
return "DEFAULT" unless had_old | ||
return old ? old : nil | ||
end | ||
|
||
end |