From 91a265c3a56dbca6435185a15dcd4c7d510db36a Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sat, 28 Mar 2026 15:17:26 -0400 Subject: [PATCH] Fix process_alive panic on u32 PID values exceeding i32::MAX The cast_possible_wrap lint fix changed `pid as i32` to `i32::try_from(pid).unwrap()`, but the unwrap panics when the PID exceeds i32::MAX (e.g. u32::MAX used in tests). Return false instead since such values are not valid Unix PIDs. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/crates/fabro-cli/src/commands/run/launcher.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/crates/fabro-cli/src/commands/run/launcher.rs b/lib/crates/fabro-cli/src/commands/run/launcher.rs index 37dd85fbb..c7356d8b3 100644 --- a/lib/crates/fabro-cli/src/commands/run/launcher.rs +++ b/lib/crates/fabro-cli/src/commands/run/launcher.rs @@ -64,7 +64,10 @@ pub(crate) fn launcher_record_is_running(record: &LauncherRecord) -> bool { #[cfg(unix)] #[allow(unsafe_code)] fn process_alive(pid: u32) -> bool { - unsafe { libc::kill(i32::try_from(pid).unwrap(), 0) == 0 } + let Ok(pid) = i32::try_from(pid) else { + return false; + }; + unsafe { libc::kill(pid, 0) == 0 } } #[cfg(not(unix))]