diff --git a/Cargo.toml b/Cargo.toml index 4b29c9b0b..989639404 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,6 @@ generic = [ "hostname", "nproc", "sync", - "tail", "whoami", "redox_generic" ] @@ -129,6 +128,7 @@ redox_generic = [ "split", "sum", "tac", + "tail", "tee", "test", "tr", diff --git a/src/tail/Cargo.toml b/src/tail/Cargo.toml index 3d96eacb7..06f8d7920 100644 --- a/src/tail/Cargo.toml +++ b/src/tail/Cargo.toml @@ -15,6 +15,9 @@ libc = "0.2.26" winapi = "0.3" uucore = { path="../uucore" } +[target.'cfg(target_os = "redox")'.dependencies] +redox_syscall = "0.1" + [[bin]] name = "tail" path = "../../uumain.rs" diff --git a/src/tail/platform/mod.rs b/src/tail/platform/mod.rs index 98960049d..010c5c4ac 100644 --- a/src/tail/platform/mod.rs +++ b/src/tail/platform/mod.rs @@ -13,8 +13,14 @@ pub use self::unix::{supports_pid_checks, Pid, ProcessChecker}; #[cfg(windows)] pub use self::windows::{supports_pid_checks, Pid, ProcessChecker}; +#[cfg(target_os = "redox")] +pub use self::redox::{supports_pid_checks, Pid, ProcessChecker}; + #[cfg(unix)] mod unix; #[cfg(windows)] mod windows; + +#[cfg(target_os = "redox")] +mod redox; diff --git a/src/tail/platform/redox.rs b/src/tail/platform/redox.rs new file mode 100644 index 000000000..c0d43cb1c --- /dev/null +++ b/src/tail/platform/redox.rs @@ -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 +}