From 1aebfe290cf64f1a772dee680ec5717a3aaaa0ea Mon Sep 17 00:00:00 2001 From: Christopher Dryden Date: Sun, 7 Dec 2025 18:33:31 +0000 Subject: [PATCH] Removing the unsafe libc call and replacing with nix --- src/uucore/src/lib/features/process.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/uucore/src/lib/features/process.rs b/src/uucore/src/lib/features/process.rs index 1019dfc5c..1c83759e1 100644 --- a/src/uucore/src/lib/features/process.rs +++ b/src/uucore/src/lib/features/process.rs @@ -10,6 +10,10 @@ use libc::{gid_t, pid_t, uid_t}; #[cfg(not(target_os = "redox"))] use nix::errno::Errno; +#[cfg(not(target_os = "openbsd"))] +use nix::sys::signal::kill; +#[cfg(not(target_os = "openbsd"))] +use nix::unistd::Pid; use std::io; use std::process::Child; use std::process::ExitStatus; @@ -72,7 +76,7 @@ pub fn pid_is_alive(pid: i32) -> bool { if pid <= 0 { return true; } - unsafe { libc::kill(pid, 0) == 0 || Errno::last() != Errno::ESRCH } + kill(Pid::from_raw(pid), None).is_ok() || Errno::last() != Errno::ESRCH } /// `getsid()` returns the session ID of the process with process ID pid.