mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Port 'tail' to Redox
This commit is contained in:
+1
-1
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user