Merge pull request #625 from Franklin-Qi/remove-libc-in-ps

ps: remove libc in ps
This commit is contained in:
Krysztal Huang
2026-02-10 17:01:28 +08:00
committed by GitHub
3 changed files with 8 additions and 13 deletions
Generated
+1 -1
View File
@@ -2277,8 +2277,8 @@ version = "0.0.1"
dependencies = [
"chrono",
"clap",
"nix 0.30.1",
"prettytable-rs",
"rustix",
"uu_pgrep",
"uucore",
]
+2 -2
View File
@@ -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" }
+5 -10
View File
@@ -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,
}
}