mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
Port 'tail' to Redox
This commit is contained in:
parent
5880c65bbb
commit
fa867e93ea
4 changed files with 35 additions and 1 deletions
|
@ -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;
|
||||
|
|
25
src/tail/platform/redox.rs
Normal file
25
src/tail/platform/redox.rs
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue