Repository navigation
Signal.list on Windows is MRI's: the C runtime's eight signals - #162
Conversation
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]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
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]>
Follow-up to #161. On Windows, IronRuby's
Signal.listhad every Linux signal. Code that checksSignal.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:
Signal.listtrap(:HUP),trap("SIGUSR1", ...),trap(:PIPE, ...)ArgumentError: unsupported signal 'SIGHUP'Process.kill(:QUIT, pid)ArgumentError: unsupported signalProcess.kill(1, pid)Errno::EINVALErrno::EINVALSignalException.new(:PIPE)ArgumentError: unsupported signal#<SignalException: SIGPIPE>Signal.signame(1)trap(:ABRT, ...)returnsPosixSignals: the name table is a Windows one (_windowsNumbers) or the Linux one, picked once at startup. A newIsUnsupportedOnWindowsmakesProcess.killreturn EINVAL for a number Windows doesn't have.InitialCommandkeeps ABRT's nil at its Windows number.Ractor_RequireInMain1trappedUSR2, which Windows doesn't have; it trapsTERMnow.Tests
Signal_WindowsList1: the same output on both platforms, and identical to CRuby's on both Linux (4.0.9) and Windows (4.0.5).Ractor_RequireInMain1, the USR2 test above; it passes after the change.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)
trap(:KILL),trap(9),trap(:STOP)Errno::EINVAL: Invalid argument - SIGKILLArgumentError: Signal already used by VM or OS: SIGKILLErrno::EINVAL, same messagetrap(:EXIT) {}returns"SYSTEM_DEFAULT"trap(:EXIT, ...)after"DEFAULT","IGNORE"or nil returnsSignalException.new(16)SIG16, signo 16 (any n up to NSIG: 65 on Linux, 23 on Windows)ArgumentError: invalid signal number (16)SIG16, 16New 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.rbandcore/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 inSignal.listbut 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::ENOTTYfortrap(1)).🤖 Generated with Claude Code
Summary by CodeRabbit
SignalExceptionaccepts in-range signal numbers even when they have no listed name; out-of-range numbers remain invalid.Process.kill.