Skip to content

Signal.list on Windows is MRI's: the C runtime's eight signals - #162

Merged
Largo merged 2 commits into
masterfrom
claude/windows-signal-list
Nov 8, 2026
Merged

Largo merged 2 commits into
masterfrom
claude/windows-signal-list

Conversation

@Largo

@Largo Largo commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #161. On Windows, IronRuby's Signal.list had every Linux signal. Code that checks Signal.list.key?("HUP") before trapping HUP (servers, job runners) therefore trapped it, and got a handler nothing could ever call.

What changes (Windows only; Linux is unchanged)

Checked against CRuby 4.0.5 x64-mingw-ucrt in the spinel-windows VM:

CRuby on Windows IronRuby before after
Signal.list EXIT 0, INT 2, ILL 4, ABRT 22, FPE 8, KILL 9, SEGV 11, TERM 15 all 33 Linux names, ABRT 6 same as CRuby
trap(:HUP), trap("SIGUSR1", ...), trap(:PIPE, ...) ArgumentError: unsupported signal 'SIGHUP' installed a handler same as CRuby
Process.kill(:QUIT, pid) ArgumentError: unsupported signal 1 same as CRuby
Process.kill(1, pid) Errno::EINVAL 1 Errno::EINVAL
SignalException.new(:PIPE) ArgumentError: unsupported signal #<SignalException: SIGPIPE> same as CRuby
Signal.signame(1) nil "HUP" nil
first trap(:ABRT, ...) returns nil nil nil
  • PosixSignals: the name table is a Windows one (_windowsNumbers) or the Linux one, picked once at startup. A new IsUnsupportedOnWindows makes Process.kill return EINVAL for a number Windows doesn't have. InitialCommand keeps ABRT's nil at its Windows number.
  • Ractor_RequireInMain1 trapped USR2, which Windows doesn't have; it traps TERM now.

Tests

  • New Signal_WindowsList1: the same output on both platforms, and identical to CRuby's on both Linux (4.0.9) and Windows (4.0.5).
  • IronRuby.Tests, Debug net8.0: all passed on Linux. On Windows (spinel-windows VM, 1107 tests) the one failure was Ractor_RequireInMain1, the USR2 test above; it passes after the change.
  • mspec on Linux: core/process/kill_spec.rb, core/signal, core/exception/interrupt_spec.rb, core/exception/signal_exception_spec.rb: 93 examples, 0 failures.

Also fixed: three differences on every platform (second commit)

CRuby 4.0 (Linux and Windows) IronRuby before after
trap(:KILL), trap(9), trap(:STOP) Errno::EINVAL: Invalid argument - SIGKILL ArgumentError: Signal already used by VM or OS: SIGKILL Errno::EINVAL, same message
first trap(:EXIT) {} returns nil "SYSTEM_DEFAULT" nil
trap(:EXIT, ...) after "DEFAULT", "IGNORE" or nil returns nil that string nil (a Proc is still returned)
SignalException.new(16) SIG16, signo 16 (any n up to NSIG: 65 on Linux, 23 on Windows) ArgumentError: invalid signal number (16) SIG16, 16

New test Signal_TrapEdges1: the same output on both platforms, identical to CRuby's on Linux and Windows. After this commit: IronRuby.Tests all passed on Linux and on Windows (1108 tests). mspec on Linux, core/signal, core/exception, core/process/kill_spec.rb, core/kernel/trap_spec.rb and core/kernel/at_exit_spec.rb: 337 examples, 0 failures. ruby/spec's KILL/STOP spec accepts either error class.

Not changed

  • trap(n) with a number that is not in Signal.list but is below NSIG: CRuby on Linux accepts most of them (16, 40, 64), and IronRuby says "invalid signal number". On Windows CRuby raises odd errnos for these (Errno::ENOTTY for trap(1)).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Compatibility
    • Signal listings and supported signal numbers now reflect the platform, including Windows-specific behavior.
    • SignalException accepts in-range signal numbers even when they have no listed name; out-of-range numbers remain invalid.
  • Bug Fixes
    • Unsupported Windows signals now return an error from Process.kill.
    • KILL and STOP trap attempts now raise the expected system error. EXIT trap handling now returns the expected previous-command value.
  • Tests
    • Added coverage for platform-specific signal listings, signal validation, and trap behavior.

IronRuby listed every Linux signal on Windows, so code that checks
Signal.list.key?("HUP") before trapping HUP went ahead and got a handler
that nothing would ever call. MRI on Windows lists EXIT, INT, ILL, ABRT,
FPE, KILL, SEGV and TERM, with ABRT as 22 (the C runtime's number).
Other names are now "unsupported signal 'SIGHUP'" in trap, Process.kill
and SignalException.new, and Process.kill with a number Windows does not
have raises Errno::EINVAL, as in MRI. Linux is unchanged.

Ractor_RequireInMain1 trapped USR2, which Windows does not have; it
traps TERM now, which both platforms have.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes add a Windows-specific signal table, update signal handling for unsupported signals, and adjust trap and SignalException behavior. Tests cover platform-specific signal listings, trap edge cases, and Ractor trap isolation.

Changes: Signal compatibility

Layer / File(s) Summary
Platform signal mapping and lookup
Src/Libraries/Builtins/PosixSignals.cs, Src/Libraries/Builtins/RubyProcess.cs, Src/IronRuby.Tests/Runtime/MiscTests.cs, Src/IronRuby.Tests/RubyTests.cs
The signal table now uses a Windows-specific mapping on Windows. Process.kill returns -EINVAL for unsupported Windows signals. Tests check platform signal listings and unsupported signals.
Trap and exception behavior
Src/Libraries/Builtins/PosixSignals.cs, Src/StdLib/ironruby/ruby4.rb, Src/IronRuby.Tests/Runtime/MiscTests.cs, Src/IronRuby.Tests/Runtime/RactorTests.cs, Src/IronRuby.Tests/RubyTests.cs
KILL and STOP traps now raise EINVAL. EXIT trap calls return nil for prior null or string handlers. SignalException accepts in-range integers without listed names. Tests cover trap edge cases and Ractor trap isolation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: claude, sholden

Merge Risk: Minimal · up to d6ff0

The supplied evidence identifies no actionable issue that would prevent merging after normal checks.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: on Windows, Signal.list now matches MRI and exposes the C runtime's eight signals. The raw summary confirms PosixSignals.cs selects a Windows-specific C-runtime table…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the main change: on Windows, Signal.list now matches MRI and exposes the C runtime's eight signals. The raw summary confirms PosixSignals.cs selects a Windows-specific C-runtime table, with ABRT as 22, and the objectives describe the same change. The title is specific and concise, and it names the primary behavior change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b4718d3 and d6ff02d.

Files selected for processing: 6

  • Src/IronRuby.Tests/RubyTests.cs
  • Src/IronRuby.Tests/Runtime/MiscTests.cs
  • Src/IronRuby.Tests/Runtime/RactorTests.cs
  • Src/Libraries/Builtins/PosixSignals.cs
  • Src/Libraries/Builtins/RubyProcess.cs
  • Src/StdLib/ironruby/ruby4.rb

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Three places IronRuby differed from MRI 4.0 on every platform:

- Trapping KILL or STOP raised ArgumentError "Signal already used by VM
  or OS"; MRI 4.0 passes on the kernel's Errno::EINVAL
  ("Invalid argument - SIGKILL"). ruby/spec accepts either.
- trap(:EXIT) reported "SYSTEM_DEFAULT" the first time and "DEFAULT" or
  "IGNORE" after those; MRI reports the old handler only when it is
  callable, and nil otherwise.
- SignalException.new(16) was "invalid signal number" because
  Signal.list has no 16; MRI takes any number up to NSIG (65 on Linux,
  23 on Windows) and calls it "SIG16".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Largo
Largo merged commit 9170dd0 into master Nov 8, 2026
8 checks passed
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