Skip to content

Signal.signame(9) raises on Windows, though Signal.list["KILL"] is 9 #10080

Closed

Description

@sferik

Environment Information

  • JRuby 10.1.3.0
  • Temurin 21.0.13, on GitHub's windows-latest runners
  • Windows Server 2025

Expected Behavior

p Signal.list["KILL"]
p Signal.signame(9)

This should print 9 and "KILL", as it does on CRuby on Windows, which defines SIGKILL as 9 and builds Signal.list and Signal.signame from the same table:

https://github.com/ruby/ruby/blob/06b18f11f4b0078e2683c661e7762fff7c04636c/include/ruby/win32.h#L425-L427

Actual Behavior

Signal.list["KILL"] is 9, but Signal.signame(9) raises:

ArgumentError: invalid signal number: 9
    org/jruby/RubySignal.java:211:in 'signame'

I think this goes back to #5430, which made Windows define KILL as 9 even though jnr-constants doesn't define SIGKILL there. It adds KILL to the map of names to numbers that Signal.list reads, but not to the map of numbers to names that Signal.signame reads:

// We always define KILL as 9 on Windows
if (Platform.IS_WINDOWS) {
signals.put("KILL", 9);
}

Adding signums.put(9, "KILL") beside signals.put("KILL", 9) should fix it. The other signals jnr-constants defines on Windows (INT, ILL, ABRT, FPE, SEGV and TERM) go into both maps, so I think KILL is the only one affected.

I ran into this in Duel, which names the signal that killed a process with Signal.signame, and now falls back to the signal's number when that raises.

Activity

  1. sferik commented on Nov 16, 2026

    @sferik
    ContributorAuthor

    One more difference I found since, which isn't Windows's alone: for a number with no signal, JRuby's Signal.signame raises where CRuby's returns nil. On JRuby 10.1.2.0, on macOS:

    $ jruby -e 'p Signal.signame(99)'
    ArgumentError: invalid signal number: 99
      signame at org/jruby/RubySignal.java:210
       <main> at -e:1
    $ ruby -e 'p Signal.signame(99)'
    nil
    

    CRuby's sig_signame returns nil for a number signo2signm has no name for:

    https://github.com/ruby/ruby/blob/06b18f11f4b0078e2683c661e7762fff7c04636c/signal.c#L310-L315

    JRuby's raises an ArgumentError there, on every platform (0 aside, which is "EXIT"):

    @JRubyMethod(meta = true)
    public static IRubyObject signame(ThreadContext context, final IRubyObject recv, IRubyObject rubySig) {
    long sig = toInt(context, rubySig);
    String signame = signo2signm(sig);
    if (signame == null) {
    if (sig == 0) return newString(context, "EXIT");
    throw argumentError(context, "invalid signal number: " + rubySig);
    }
    return newString(context, signame);
    }

    So code written for CRuby that checks for nil (to name a signal by its number instead, say) gets an exception on JRuby. Returning nil there would match CRuby, and on Windows, Signal.signame(9) would then return nil rather than raise even before KILL is mapped.

  2. added this to the JRuby 10.1.4.0 milestone on Nov 17, 2026
  3. headius commented on Nov 17, 2026

    @headius
    Member

    I already merged the signel 9 PR but if you want to fix the additional issue go for it. Behavior should always match CRuby unless we have a really good reason not to.

  4. headius commented on Nov 17, 2026

    @headius
    Member

    Main issue fixed by #10083. Additional issue moved to #10094.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions