mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-08-28 05:27:41 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
parent
007d716f2b
commit
91a265c3a5
1 changed files with 4 additions and 1 deletions
|
|
@ -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))]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue