Repository navigation
Conversation
CRuby's signo2signm returns the first name in siglist with the given number, so Signal.signame(6) is "ABRT", not its alias "IOT". JRuby built its number-to-name map from jnr-constants' Signal enum and kept the last name it saw, so IOT replaced ABRT. Build the map from a list of names in CRuby's siglist order and keep the first name for each number. This replaces the SIGNAME switch, which held the same names. Signal.list is unchanged. Also remove a stale tag that no longer matched any spec name.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signal.signame(6) returns "IOT" on JRuby, but "ABRT" on CRuby. CRuby's signo2signm returns the first name in siglist with that number, and ABRT comes before its alias IOT:
https://github.com/ruby/ruby/blob/06b18f11f4b0078e2683c661e7762fff7c04636c/signal.c#L92-L97
https://github.com/ruby/ruby/blob/06b18f11f4b0078e2683c661e7762fff7c04636c/signal.c#L283-L293
JRuby built its number-to-name map by looping over jnr-constants' Signal enum and keeping the last name it saw for each number. The enum has SIGIOT after SIGABRT, so IOT won. On Linux, SIGIO comes after SIGPOLL in the enum, so IO wins there and matches CRuby, but only by chance.
I replaced the SIGNAME switch, which already held CRuby's signal names, with an array in siglist order, and the map now keeps the first name for each number. Signal.list is the same as before. I also removed the two tags for the precedence spec. One of them had an old spelling and didn't match any spec any more.
I checked that Signal.list is unchanged on macOS and that Signal.signame gives the same name as CRuby for every number in it. spec/ruby/core/signal, process/kill_spec.rb and kernel/trap_spec.rb pass, and spec/ruby/core/signal also passes with the JIT. I couldn't test on Linux or Windows.
The other tag in signame_tags.txt is removed in #10098. Both PRs change that file, so whichever merges second may need a small rebase.
One thing I noticed but didn't change: Signal.list on JRuby has no EMT or INFO on macOS, because jnr-constants' Signal enum doesn't define them. CRuby has both.