Repository navigation
Process.kill to yourself: Interrupt for INT, MRI's default after a trap - #161
Conversation
A process that signalled itself with SIGINT and had no handler got a
SignalException ("SIGINT"), which `rescue Interrupt` does not catch. MRI
raises Interrupt, with an empty message and #signo 2; the Ctrl-C and
trap(:INT, "DEFAULT") paths now use the same empty message.
PIPE, SYS and VTALRM, which MRI swallows unless trapped, raised a
SignalException; sending one of them to yourself is now a no-op.
A signal trapped back to "DEFAULT" (trap(:TERM, old)) was swallowed by
the empty handler entry the trap left behind; it raises SignalException
again, and "SYSTEM_DEFAULT" goes to the real kill(2) as in MRI.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Found while testing #154 on Windows: a check that sent INT to its own process got
SignalExceptioninstead ofInterrupt. Older than #154 and unrelated to it.What changes
When a process signals itself,
Process.killstands in for the signal rather than letting the real one kill .NET. That stand-in now matches CRuby 4.0 (checked againstruby 4.0.9on Linux andruby 4.0.5x64-mingw-ucrt on Windows):Process.kill(sig, Process.pid), no trapInterrupt, message"",signo2SignalException"SIGINT" (Windows; Linux gaveInterruptwith message "Interrupt")Interrupt,"", 2SignalException"SIGxxx"SignalExceptionold = trap(:TERM) {...}; trap(:TERM, old)SignalExceptionSignalExceptiontrap(:TERM, "SYSTEM_DEFAULT")RubyProcess.Kill: raisesInterrupt("")for INT; skips PIPE/SYS/VTALRM; treats a signal trapped back toDEFAULTorSYSTEM_DEFAULTas untrapped (PosixSignals.HasRubyHandler), and letsSYSTEM_DEFAULTgo to the realkill(2).Program.cs) andtrap(:INT, "DEFAULT")(Signal.cs) raiseInterruptwith the same empty message CRuby uses. An uncaught one still printsInterruptand exits 130, as CRuby does.Tests
Process_KillSelfInterrupt1; its expected output is CRuby 4.0's output for the same script.core/process/kill_spec.rb,core/signal,core/exception/interrupt_spec.rb,core/exception/signal_exception_spec.rb: 93 examples, 0 failures.Not changed
trap(:TERM, "SYSTEM_DEFAULT")followed by a self-kill still does nothing (CRuby ends the process). The Windows self-kill path has no real signal to send.SignalExceptionfor them.Signal.liston Windows has all the POSIX names. CRuby on Windows lists only EXIT, INT, ILL, ABRT, FPE, KILL, SEGV, TERM.🤖 Generated with Claude Code
Summary by CodeRabbit
SIGINTnow raises an interrupt with an empty message, while other terminating signals raise a signal exception unless a handler or system-default trap applies.PIPE,SYS, andVTALRM, are now skipped when sent to the current process."DEFAULT"restores its default handling behavior.