1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Merge pull request #1168 from ids1024/tail-redox

Port 'tail' to Redox
This commit is contained in:
Alex Lyon 2018-03-18 22:18:27 -07:00 committed by GitHub
commit eab4cf6f58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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
}