1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

Port 'tail' to Redox

This commit is contained in:
Ian Douglas Scott 2018-03-18 21:56:26 -07:00
parent 5880c65bbb
commit fa867e93ea
No known key found for this signature in database
GPG key ID: 4924E10E199B5959
4 changed files with 35 additions and 1 deletions

View file

@ -68,7 +68,6 @@ generic = [
"hostname", "hostname",
"nproc", "nproc",
"sync", "sync",
"tail",
"whoami", "whoami",
"redox_generic" "redox_generic"
] ]
@ -129,6 +128,7 @@ redox_generic = [
"split", "split",
"sum", "sum",
"tac", "tac",
"tail",
"tee", "tee",
"test", "test",
"tr", "tr",

View file

@ -15,6 +15,9 @@ libc = "0.2.26"
winapi = "0.3" winapi = "0.3"
uucore = { path="../uucore" } uucore = { path="../uucore" }
[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall = "0.1"
[[bin]] [[bin]]
name = "tail" name = "tail"
path = "../../uumain.rs" path = "../../uumain.rs"

View file

@ -13,8 +13,14 @@ pub use self::unix::{supports_pid_checks, Pid, ProcessChecker};
#[cfg(windows)] #[cfg(windows)]
pub use self::windows::{supports_pid_checks, Pid, ProcessChecker}; pub use self::windows::{supports_pid_checks, Pid, ProcessChecker};
#[cfg(target_os = "redox")]
pub use self::redox::{supports_pid_checks, Pid, ProcessChecker};
#[cfg(unix)] #[cfg(unix)]
mod unix; mod unix;
#[cfg(windows)] #[cfg(windows)]
mod windows; mod windows;
#[cfg(target_os = "redox")]
mod redox;

View file

@ -0,0 +1,25 @@
extern crate syscall;
use self::syscall::{Error, EPERM, ENOSYS};
pub type Pid = usize;
pub struct ProcessChecker {
pid: self::Pid,
}
impl ProcessChecker {
pub fn new(process_id: self::Pid) -> ProcessChecker {
ProcessChecker { pid: process_id }
}
// Borrowing mutably to be aligned with Windows implementation
pub fn is_dead(&mut self) -> bool {
let res = syscall::kill(self.pid, 0);
res != Ok(0) && res != Err(Error::new(EPERM))
}
}
pub fn supports_pid_checks(pid: self::Pid) -> bool {
true
}