Repository navigation
Conversation
When a lifecycle script subprocess terminated via a Linux real-time signal (32..64), handle_exit routed through Status::signal_code(), which range-checks 1..=31 and returns None for RT signals. The fallback re-raised SIGTERM instead of the original signal, so a parent waiting on bun install observed WTERMSIG=15 rather than the RT signal the script was actually killed with. Forward the raw signal byte via raise_ignoring_panic_handler_raw, the same pattern bunx and run_command already use, matching the original Zig behavior.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughIn ChangesRT Signal Re-raise Fix
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
Status: diff is green; the one red CI lane is a darwin agent infra failure. Build #62589: 285/286 jobs passed. The single failure is Reproduced on Linux with a root Review flagged three more pre-existing sites with the same RT-signal lossiness ( |
|
Updated 12:23 PM PT - Jun 15th, 2026
❌ @robobun, your commit e539233 has some failures in 🧪 To try this PR locally: bunx bun-pr 32305That installs a local version of the PR into your bun-32305 --bun |
There was a problem hiding this comment.
LGTM — minimal fix matching the established raise_ignoring_panic_handler_raw pattern; the inline comments are all nits or pre-existing follow-ups.
Extended reasoning...
Overview
The PR changes one match arm in src/install/lifecycle_script_runner.rs::handle_exit: instead of routing the raw signal byte through Status::signal_code() (which returns None for signals >31) and falling back to SIGTERM, it now calls Global::raise_ignoring_panic_handler_raw(c_int::from(signal)) directly. Net diff is −8/+3 lines plus a ~40-line Linux-only regression test in bun-install-lifecycle-scripts.test.ts.
Correctness
The replacement function is explicitly documented for this exact case (Global.rs:681-684: "Callers may forward any signal byte (incl. Linux RT signals 32..=64) that has no crate::SignalCode discriminant"), and the identical call pattern already exists at run_command.rs:2264 and bunx_command.rs:1352/1370. signal is a u8 so c_int::from(signal) is a lossless widening. For named POSIX signals 1..=31 the behavior is unchanged (raise_ignoring_panic_handler was already just raise_ignoring_panic_handler_raw(sig as c_int)); only the RT-signal range now forwards correctly instead of collapsing to SIGTERM.
Security risks
None. The code path is already process-terminating (-> !); the only observable change is which signal number the parent re-raises to its own parent. No new inputs, no auth/crypto/permissions surface.
Level of scrutiny
Low. This is a 3-line mechanical swap to a sibling function that is purpose-built and already in use at three other call sites for the same problem. The Zig reference (lifecycle_script_runner.zig:451) does the same raw forward. The test is deterministic (per the bug-hunter's analysis, .exited is read synchronously so it always takes the 128+sig path) and gated to Linux where RT signals exist.
Other factors
All four bug-hunter findings are non-blocking: two are pre-existing RT-signal lossiness in other files not touched here (good follow-up material), one is a CLAUDE.md comment-style nit (drop the bug-history line), and one is test-organization (test sits outside the describe.concurrent block but is still correct and uniquely named for both forceWaiterThread values). None affect the correctness of this fix. No CODEOWNERS cover these paths and there are no outstanding human review comments.
There was a problem hiding this comment.
LGTM — both nits addressed in 55c8f9d; the raw-signal forward matches the existing bunx_command.rs/run_command.rs:2264 pattern and raise_ignoring_panic_handler_raw's documented purpose.
Extended reasoning...
Overview
Effectively a one-line behavior change in src/install/lifecycle_script_runner.rs's Status::Signaled arm: replace Status::Signaled(signal).signal_code().unwrap_or(SIGTERM) → raise_ignoring_panic_handler_raw(c_int::from(signal)), plus a Linux-only regression test in bun-install-lifecycle-scripts.test.ts. The fix forwards the raw signal byte so Linux RT signals (32..64) are re-raised unchanged instead of collapsing to SIGTERM.
Security risks
None. This is process-exit signal propagation on a path that already calls raise_ignoring_panic_handler and diverges; the only change is which signal number is passed. No auth, crypto, parsing, or user-controlled-data surface.
Level of scrutiny
Low. The new call is byte-identical to established precedent at bunx_command.rs:1352/1370 and run_command.rs:2264, and Global::raise_ignoring_panic_handler_raw (Global.rs:684) is documented for exactly this case ("forward any signal byte incl. Linux RT signals 32..=64"). For named POSIX signals 1..=31 behavior is unchanged (raise_ignoring_panic_handler(sig) already delegated to _raw(sig as c_int)). No CODEOWNERS entry covers src/install/.
Other factors
My prior review raised two nits (bug-history comment; test placed outside the describe.concurrent block) and two pre-existing/non-blocking observations. Commit 55c8f9d addressed both nits — verified the test now sits inside the lifecycle scripts describe (closes at line 3275) with the manual waiter-thread suffix removed and the bug-history comment dropped. The two pre-existing items (other RT-signal-lossy sites in run_command.rs/filter_run.rs/multi_run.rs; subprocess.rs .exited divergence) were acknowledged as follow-ups, which is the right scoping. The bug-hunting pass on this revision found nothing.
There was a problem hiding this comment.
LGTM — both nits addressed in 55c8f9d; the one-line swap to raise_ignoring_panic_handler_raw matches the existing pattern in bunx_command.rs/run_command.rs:2264 and is byte-identical for signals 1..=31.
Extended reasoning...
Overview
This PR is a one-line behavior fix in src/install/lifecycle_script_runner.rs's handle_exit Status::Signaled arm: it replaces Global::raise_ignoring_panic_handler(Status::Signaled(signal).signal_code().unwrap_or(SIGTERM)) with Global::raise_ignoring_panic_handler_raw(c_int::from(signal)), plus a Linux-only regression test in bun-install-lifecycle-scripts.test.ts that asserts bun install terminates with 128 + 35 = 163 when a postinstall script kills itself with signal 35.
Security risks
None. This is the process-termination path after a lifecycle-script child has already been killed by a signal; the only change is which integer is passed to raise(). Global.rs:677-678 shows the typed raise_ignoring_panic_handler(SignalCode) is itself just raise_ignoring_panic_handler_raw(sig as c_int), so for the previously-supported range (1..=31) the new call is byte-identical. The only behavioral delta is that Linux RT signals 32..=64 are now forwarded faithfully instead of collapsing to SIGTERM — which is the documented purpose of _raw (Global.rs:682-684) and matches the Zig reference. No new inputs, no auth/crypto/permissions, no data exposure.
Level of scrutiny
Low. The fix is a mechanical swap to an existing helper that two other call sites (bunx_command.rs:1352,1370 and run_command.rs:2264) already use for exactly this case, so there's established precedent in the codebase. The change is on a fatal-exit path (the parent is about to die regardless), so the blast radius for regression is the exit signal value — which the new test pins.
Other factors
I left two style nits and two pre-existing/non-blocking observations on the previous revision. The author addressed both actionable nits in 55c8f9d: the test now sits inside the describe.concurrent("lifecycle scripts"...) block (line 3240, closing }); at 3275 before the next describe) without the hand-rolled (waiter thread) suffix, and the bug-history comment line is gone (only the 128 + WTERMSIG = 163 invariant remains at line 3268). The two 🟣 pre-existing items (RT-signal lossiness in run_command.rs:474, filter_run.rs, multi_run.rs; and the Subprocess.exited already-exited-path divergence) were acknowledged for follow-up and are out of scope here. robobun reports CI green (280 passed, 0 failures); the stalled darwin lanes are agent-availability, and the new test is skipIf(!isLinux) anyway.
Status::signal_code() routed the raw signal byte through
bun_core::SignalCode::from_raw, which only covers the named 1..=31
range and returns None for anything else. On Linux a child can be
killed by a real-time signal (SIGRTMIN..SIGRTMAX, typically 34..64).
For those:
* Bun.spawn subprocess.signalCode became null instead of the
numeric signal, and subprocess.exitCode was also null
* node:child_process emitted 'exit'/'close' with (null, null),
breaking the "one of code/signal is always non-null" contract
* Bun.$ shell on_process_exit() fell through to exit_code = None
and never called cmd.on_exit(), leaving the command unfinished
Status::signal_code() / Process::signal_code() now return
Option<bun_sys::SignalCode> (the open u8 newtype) for any non-zero
byte. get_signal_code() returns the numeric signal when there is no
name. Shell on_process_exit() computes 128 + sig directly from the
Status::Signaled payload so RT-signaled commands complete.
The now-redundant SignalCodeExt trait is removed
(bun_sys::SignalCode already has to_exit_code()).
The lifecycle_script_runner.rs hunk is the same change as #32305.
|
Superseded by #39970, which makes the lifecycle runner re-raise the raw signal together with the other re-raise sites, and carries a test for a real-time signal in bun-install-lifecycle-scripts.test.ts. |
…umbers (#39970) Fixes #35296 ### Problem - On macOS, `subprocess.signalCode` names the platform's number with the Linux table: a child killed by SIGBUS (10 there) reports `"SIGUSR1"` (build 102638). `kill("SIGUSR1")` sends 10, which is SIGBUS there. - A signal with no name (a Linux real-time signal) is handled four ways: `exited` is 128 + n or 254, `bun run` exits 1, `Bun.$` never completes, and `signalCode` is null. - Cause: `bun_core::SignalCode` (`src/bun_core/Global.rs:239`) has Linux numbers on every platform. `Status::signal_code()` (`src/spawn/process.rs:768`) looked the raw `WTERMSIG` number up in it, and `kill()` sent the table's number. ### Fix - `bun_core::SignalCode` holds only the signals the target has, and a discriminant is the target's own number: `libc::SIG*` on unix, the CRT and libuv numbers on Windows. `platform_number()` (#34660) and each `None` fallback are gone. Signal 16 on Linux is `SIGSTKFLT`, node's name. - `Status::signal()` is the raw platform number. Exit codes, re-raises and `signalCode` use it. `Status::signal_code()` is the named signal, used only to name or classify. - Correct because a variant cannot exist without a number, so each conversion to the OS is a cast. A number without a name is reported as the number. A name the platform lacks is an unknown name. - Verified: new cases in seven test files (see the notes), with cases that fail on stock bun on Linux. Also `cargo check` for five targets and a Windows debug build. ### Background - Signal numbers are per OS. Linux and the BSDs agree on about half of them. SIGSTKFLT and real-time signals are Linux-only. Windows has six CRT signals, and libuv adds four. - `bun_core::SignalCode` is a closed enum generated from one table. Its variant names are what JS sees. - `bun_sys::SignalCode(u8)` is the open newtype for any platform number, which may have no name. <details><summary>Notes</summary> - New test cases: spawn-kill-signal, child_process, shell-hang, run-propagate-sigkill, filter-workspace, bun-install-lifecycle-scripts, parallel. - Superseded and closed: #33775 (the SIGSTKFLT name), #32305 and #32321 (a signal with no name). - Shape history: the first version kept the Linux-numbered table and converted at the OS boundary with `platform_number()` and a new inverse. Review asked for no abort or panic fallbacks, so the table itself is per platform now. `raise_ignoring_panic_handler()` is unchanged from main (`sig as c_int` is correct once a discriminant is the platform's number), `bun_sys::SignalCode::of()` is a cast, the kill-signal parser has no `ERR_UNKNOWN_SIGNAL` branch, and `--watch-kill-signal` has no `platform_number().is_some()` filter and no `unwrap_or(SIGTERM)`. The one `Option` left is `from_number()`, because a real-time signal has no name. - The table: the unix rows take their numbers from `libc`, so there is no per-OS numbering to keep in sync, and the compiler rejects two variants with one number. SIGSTKFLT and SIGPWR are `cfg(any(linux, android))`. The Windows rows are the ten numbers `platform_number()` had (CRT plus libuv's `uv/win.h`). A row also carries the description for the "terminated by" messages, so the `description()` match in `bun_sys` is gone and no consumer needs a `cfg`. - A name the platform lacks: on macOS `kill("SIGPWR")` used to send signal 30, which is SIGUSR1 there. On Windows `kill("SIGUSR1")` used to throw the `ENOSYS` system error from `uv_kill`. Both now throw the existing `ERR_INVALID_ARG_TYPE` error, the same as `"SIGGOD"`, and its list holds only the platform's names. On Windows the list is `'SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGILL', 'SIGABRT', 'SIGFPE', 'SIGKILL', 'SIGSEGV', 'SIGTERM' or 'SIGWINCH'`. `--watch-kill-signal` keeps its `ERR_UNKNOWN_SIGNAL` message. node:child_process validates names in JS against `os.constants.signals`, as before. The test for this runs on macOS and Windows with SIGSTKFLT and SIGPWR. On Linux every name exists. - Windows call sites: `on_exit_uv` used `term_signal < SIGSYS` as its range check. SIGSYS is not a Windows signal, so the check is `u8::try_from(term_signal)` with 0 excluded. libuv sets `term_signal` only to a signal `uv_process_kill` accepted (SIGINT, SIGQUIT, SIGKILL, SIGTERM). `is_panic_status` reads signals only on unix. On Windows a signal status comes only from `uv_process_kill`, and none of those four is a crash signal, so the result is the same. - Surfaces that read the name: `subprocess.signalCode`, `onExit`, `Bun.spawnSync().signalCode`, node:child_process `exit`/`close`/`signalCode` and `spawnSync().signal`, the `bun test --parallel` "worker crashed" label, the `bun run --filter` label, and the `bun run` and lifecycle-script "terminated by" messages. `bun test --parallel` also classifies SIGBUS and SIGSYS deaths as crashes through the table. On macOS those two were read as SIGUSR1 and SIGUSR2 and did not abort the run, and a SIGUSR2 death was read as SIGSYS and did. - Surfaces that use the number: the `exited` promise (the one created before the exit and the one created after, which used to give 254), the shell's `$?` (the shell used to wait forever for a command killed by a real-time signal, reproduced on stock bun), the `bun run --filter` and `bun create` exit codes (used to be 1), the `bun run`, `bunx` and lifecycle re-raises (the lifecycle one used to re-raise SIGTERM), and the number the webview hooks pass to C++. - `Bun.spawn`'s `signalCode` for a signal with no name is the number. `bun.d.ts` documented that, and the code did it before the Rust port. `bun.d.ts` and `docs/runtime/child-process.mdx` now say so in the types too (`onExit`'s parameter was typed `number | null` although it received the name). - node:child_process keeps names only and reports such a death as Node does. Under Node v26.3.0 on Linux, `spawn("sh", ["-c", "kill -40 $$"])` gives `exit` and `close` `(0, null)`, `exitCode: 0`, `signalCode: null`, and `spawnSync` gives `{ status: null, signal: "" }`: `signo_string()` is `""` for a signal Node has no name for ([process_wrap.cc#L410](https://github.com/nodejs/node/blob/v26.3.0/src/process_wrap.cc#L410), [spawn_sync.cc#L732](https://github.com/nodejs/node/blob/v26.3.0/src/spawn_sync.cc#L732)), so `onexit` stores libuv's exit status, 0 ([child_process.js#L270](https://github.com/nodejs/node/blob/v26.3.0/lib/internal/child_process.js#L270)). Bun reported `(null, null)` and `signal: null`, a state Node never produces, and cluster's `isDead()` stayed false after the exit. - Fail-before on Linux comes from the Linux-visible half of each class: signal 16 was named `SIG16`, `kill("SIGSTKFLT")` threw, the CLI printed `code 16` for it, and signal 40 (a real-time signal on glibc and musl) hit every no-name path. The macOS half is covered by the same tests through SIGUSR1/SIGUSR2, which pass on Linux either way. - #35304 fixes the naming with a second X-macro table of BSD numbers. After #34660 landed `platform_number()`, that table does not build on macOS (`platform_number()` names `SIGPWR`, and the BSD table adds `SIGEMT`/`SIGINFO` variants it does not match). - `from_number()` is a linear search over the variants, once per process exit. `raise_ignoring_panic_handler_raw()` is untouched, so this does not overlap with #38877. - Removed as dead: `platform_number()`, `SIGNAL_NAMES`, `bun_core::SignalCode::from_raw()`, `bun_sys::signal_code::from_name()`, the generated `bun_sys::SignalCode::SIG*` constants (only `SIGINT`, `SIGKILL` and `DEFAULT` have users), the `description()` match in `bun_sys`, `Process::signal_code()` and the `SignalCodeExt` shim. - The tests use SIGUSR1, SIGUSR2 and, on Linux, SIGSTKFLT, because their numbers differ between Linux and the BSDs and their default action terminates without a core dump, and signals 40 and 64 for the no-name paths. The async spawn tests assert `exited === 128 + os.constants.signals[name]` as well as the name. On macOS the old code sent the wrong signal and then named it with the same wrong table, so the name alone passed. The parallel test kills with an `os.constants` number because `process.kill(pid, "SIGSTKFLT")` is a separate gap (#33776), and ASAN builds intercept a self-sent SIGBUS. - The branch is one commit on top of main plus review follow-ups. Two call sites that were new on main were adapted during the rebase: `Coordinator::abort_all` (#41467) drops `.unwrap_or(130)` because `to_exit_code()` is total, and `git_runner.rs` (#40734) uses `bun_sys::SignalCode::SIGKILL`. The shell's `Status::Err` arm (a wait error leaves `Bun.$` pending) is the same on main and is handed off as separate work. - Suites run with the Linux debug build: spawn, spawnSync, spawn-signal, spawn-maxbuf, spawn-kill-signal, bunshell, exec, shelloutput, shell-hang, filter-workspace, run-propagate-sigkill, run-crash-handler, run_command, child_process, child_process-node, parallel.test.ts, the signal cases of bun-install-lifecycle-scripts.test.ts, the three `test-watch-mode-kill-signal-*.mjs` node tests, and test/integration/bun-types. `cargo check` ran for `bun_core`, `bun_sys`, `bun_spawn`, `bun_jsc`, `bun_runtime` and `bun_install` on linux, aarch64 darwin, x86_64 windows-msvc, android and freebsd. `cargo clippy` is clean for those crates on the host. - With a Windows debug build: spawn-kill-signal.test.ts, run-crash-handler.test.ts, the signal cases of child_process.test.ts, the NTSTATUS case of parallel.test.ts, `kill("SIGKILL")` (exited 137, `signalCode` `"SIGKILL"`), and `--watch --watch-kill-signal SIGUSR1` (`ERR_UNKNOWN_SIGNAL`, exit 1). - Unrelated, seen on the way: in the Windows debug build, five other `parallel.test.ts` cases fail because the worker prints `ASSERTION FAILED: currentThreadIsHoldingAPILock()` from `JSC::VM::finalizeSynchronousJSExecution` (called from `run_as_worker` through `release_weak_refs`). The assertion is debug-only, this diff does not touch that code, and the release lanes in CI pass those cases. In this Linux container, `child_process.test.ts` has two unrelated failures: "should allow us to spawn in the default shell" (`$SHELL` is empty here) and "extra stdio pipes are not double-closed on GC" (20 debug+ASAN bun startups exceed the 5 s test timeout). "each worker has a unique JEST_WORKER_ID" in `parallel.test.ts` fails one run in three here, because a debug worker starts slower than the 200 ms the fixture sleeps. </details> <!-- robobun:evidence:begin --> --- **no test proof** · iteration 6 · platform-specific test(s) that do not run on this machine, deferring to CI, which covers all platforms: test/js/node/child_process/child_process.test.ts, test/js/bun/spawn/spawn-kill-signal.test.ts, test/js/bun/shell/shell-hang.test.ts, test/cli/test/parallel.test.ts, test/cli/run/run-propagate-sigkill.test.ts, test/cli/run/filter-workspace.test.ts, test/cli/install/bun-install-lifecycle-scripts.test.ts <!-- robobun:evidence:end -->
Problem
When a lifecycle script subprocess terminates via a Linux real-time signal (SIGRTMIN..SIGRTMAX, i.e. 32..64),
bun installre-raises SIGTERM instead of the original signal. A CI orchestrator that kills lifecycle scripts withSIGRTMIN+nand inspects the install process's termination signal sees 15 instead of the actual RT signal.Repro (Linux only)
{ "name": "foo", "version": "1.0.0", "scripts": { "postinstall": "kill -35 $$" } }Cause
handle_exitinsrc/install/lifecycle_script_runner.rsrouted the raw signal byte throughStatus::Signaled(signal).signal_code(), which range-checks 1..=31 (bun_core::SignalCodeis exhaustive over named POSIX signals) and returnsNonefor RT signals. The fallback wasunwrap_or(SignalCode::SIGTERM), so the parent re-raised 15. The Zig reference (lifecycle_script_runner.zig:451) forwards the raw value unchanged.Fix
Call
Global::raise_ignoring_panic_handler_raw(c_int::from(signal))with the raw byte, the same patternbunx_command.rsandrun_command.rsalready use for this exact case.Verification
Added a Linux-only test in
bun-install-lifecycle-scripts.test.ts(both the default and waiter-thread exit paths) that spawnsbun installwith apostinstallwhich kills itself via signal 35 and asserts the install process itself terminates with128 + 35 = 163(signalCode: null). Before the fix it terminated with{ exited: 143, signalCode: "SIGTERM" }.