Skip to content

Prefer the original signal name over an alias in Signal.signame - #10099

Open
sferik wants to merge 1 commit into
jruby:masterfrom
sferik:signame-prefers-original
Open

sferik wants to merge 1 commit into
jruby:masterfrom
sferik:signame-prefers-original

Conversation

@sferik

@sferik sferik commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant