mirror of
https://github.com/uutils/procps.git
synced 2026-06-10 16:14:00 -07:00
ps: remove libc in ps
Handling unsafe uucore::libc::getsid functions with Rustix
This commit is contained in:
Generated
+1
-1
@@ -2277,8 +2277,8 @@ version = "0.0.1"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"clap",
|
||||
"nix 0.30.1",
|
||||
"prettytable-rs",
|
||||
"rustix",
|
||||
"uu_pgrep",
|
||||
"uucore",
|
||||
]
|
||||
|
||||
@@ -14,11 +14,11 @@ version.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
uucore = { workspace = true, features = ["utmpx", "libc"] }
|
||||
uucore = { workspace = true, features = ["utmpx"] }
|
||||
clap = { workspace = true }
|
||||
chrono = { workspace = true, default-features = false, features = ["clock"] }
|
||||
prettytable-rs = { workspace = true }
|
||||
nix = { workspace = true }
|
||||
rustix = { workspace = true, features = ["fs", "process", "std", "termios"] }
|
||||
|
||||
uu_pgrep = { path = "../pgrep" }
|
||||
|
||||
|
||||
@@ -8,20 +8,15 @@ use std::collections::HashSet;
|
||||
use uu_pgrep::process::{walk_process, ProcessInformation, RunState, Teletype};
|
||||
use uucore::error::UResult;
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
use nix::errno::Errno;
|
||||
|
||||
// TODO: Temporary add to this file, this function will add to uucore.
|
||||
#[cfg(not(target_os = "redox"))]
|
||||
#[cfg(target_family = "unix")]
|
||||
fn getsid(pid: i32) -> Option<i32> {
|
||||
unsafe {
|
||||
let result = uucore::libc::getsid(pid);
|
||||
if Errno::last() == Errno::UnknownErrno {
|
||||
Some(result)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
use rustix::process::Pid;
|
||||
|
||||
match rustix::process::getsid(Pid::from_raw(pid)) {
|
||||
Ok(sid) => Some(sid.as_raw_nonzero().get()),
|
||||
Err(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user