Skip to content

Commit fd9b8be

Browse files
Merge pull request #625 from Franklin-Qi/remove-libc-in-ps
ps: remove libc in ps
2 parents acbc385 + 673d322 commit fd9b8be

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/ps/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ version.workspace = true
1414
workspace = true
1515

1616
[dependencies]
17-
uucore = { workspace = true, features = ["utmpx", "libc"] }
17+
uucore = { workspace = true, features = ["utmpx"] }
1818
clap = { workspace = true }
1919
chrono = { workspace = true, default-features = false, features = ["clock"] }
2020
prettytable-rs = { workspace = true }
21-
nix = { workspace = true }
21+
rustix = { workspace = true, features = ["fs", "process", "std", "termios"] }
2222

2323
uu_pgrep = { path = "../pgrep" }
2424

src/uu/ps/src/process_selection.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,15 @@ use std::collections::HashSet;
88
use uu_pgrep::process::{walk_process, ProcessInformation, RunState, Teletype};
99
use uucore::error::UResult;
1010

11-
#[cfg(target_family = "unix")]
12-
use nix::errno::Errno;
13-
1411
// TODO: Temporary add to this file, this function will add to uucore.
1512
#[cfg(not(target_os = "redox"))]
1613
#[cfg(target_family = "unix")]
1714
fn getsid(pid: i32) -> Option<i32> {
18-
unsafe {
19-
let result = uucore::libc::getsid(pid);
20-
if Errno::last() == Errno::UnknownErrno {
21-
Some(result)
22-
} else {
23-
None
24-
}
15+
use rustix::process::Pid;
16+
17+
match rustix::process::getsid(Pid::from_raw(pid)) {
18+
Ok(sid) => Some(sid.as_raw_nonzero().get()),
19+
Err(_) => None,
2520
}
2621
}
2722

0 commit comments

Comments
 (0)