Skip to content

Commit f61b974

Browse files
committed
uucore: remove unused getpid and getsid functions
1 parent 6100aee commit f61b974

1 file changed

Lines changed: 1 addition & 54 deletions

File tree

src/uucore/src/lib/features/process.rs

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55

6-
// spell-checker:ignore (vars) cvar exitstatus cmdline kworker getsid getpid
6+
// spell-checker:ignore (vars) cvar exitstatus cmdline kworker
77
// spell-checker:ignore (sys/unix) WIFSIGNALED ESRCH
88
// spell-checker:ignore pgrep pwait snice getpgrp
99

1010
use libc::{gid_t, pid_t, uid_t};
11-
#[cfg(not(target_os = "redox"))]
12-
use nix::errno::Errno;
1311
use nix::sys::signal::{self as nix_signal, SigHandler, Signal};
1412
use nix::unistd::Pid;
1513
use std::io;
@@ -46,35 +44,6 @@ pub fn getuid() -> uid_t {
4644
nix::unistd::getuid().as_raw()
4745
}
4846

49-
/// `getpid()` returns the pid of the calling process.
50-
pub fn getpid() -> pid_t {
51-
nix::unistd::getpid().as_raw()
52-
}
53-
54-
/// `getsid()` returns the session ID of the process with process ID pid.
55-
///
56-
/// If pid is 0, getsid() returns the session ID of the calling process.
57-
///
58-
/// # Error
59-
///
60-
/// - [Errno::EPERM] A process with process ID pid exists, but it is not in the same session as the calling process, and the implementation considers this an error.
61-
/// - [Errno::ESRCH] No process with process ID pid was found.
62-
///
63-
///
64-
/// # Platform
65-
///
66-
/// This function only support standard POSIX implementation platform,
67-
/// so some system such as redox doesn't supported.
68-
#[cfg(not(target_os = "redox"))]
69-
pub fn getsid(pid: i32) -> Result<pid_t, Errno> {
70-
let pid = if pid == 0 {
71-
None
72-
} else {
73-
Some(Pid::from_raw(pid))
74-
};
75-
nix::unistd::getsid(pid).map(Pid::as_raw)
76-
}
77-
7847
/// Missing methods for Child objects
7948
pub trait ChildExt {
8049
/// Send a signal to a Child process.
@@ -166,25 +135,3 @@ impl ChildExt for Child {
166135
Ok(None)
167136
}
168137
}
169-
170-
#[cfg(test)]
171-
mod tests {
172-
use super::*;
173-
174-
#[test]
175-
#[cfg(not(target_os = "redox"))]
176-
fn test_getsid() {
177-
assert_eq!(
178-
getsid(getpid()).expect("getsid(getpid)"),
179-
// zero is a special value for SID.
180-
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsid.html
181-
getsid(0).expect("getsid(0)")
182-
);
183-
184-
// SID never be 0.
185-
assert!(getsid(getpid()).expect("getsid(getpid)") > 0);
186-
187-
// This might caused tests failure but the probability is low.
188-
assert!(getsid(999_999).is_err());
189-
}
190-
}

0 commit comments

Comments
 (0)