Pipe OK.
This commit is contained in:
parent
e93a4a0b76
commit
2d34cab989
14 changed files with 218 additions and 18 deletions
|
@ -45,6 +45,15 @@ impl TaskControlBlockInner {
|
|||
pub fn is_zombie(&self) -> bool {
|
||||
self.get_status() == TaskStatus::Zombie
|
||||
}
|
||||
pub fn alloc_fd(&mut self) -> usize {
|
||||
if let Some(fd) = (0..self.fd_table.len())
|
||||
.find(|fd| self.fd_table[*fd].is_none()) {
|
||||
fd
|
||||
} else {
|
||||
self.fd_table.push(None);
|
||||
self.fd_table.len() - 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TaskControlBlock {
|
||||
|
@ -78,7 +87,11 @@ impl TaskControlBlock {
|
|||
children: Vec::new(),
|
||||
exit_code: 0,
|
||||
fd_table: vec![
|
||||
// 0 -> stdin
|
||||
Some(Arc::new(Stdin)),
|
||||
// 1 -> stdout
|
||||
Some(Arc::new(Stdout)),
|
||||
// 2 -> stderr
|
||||
Some(Arc::new(Stdout)),
|
||||
],
|
||||
}),
|
||||
|
@ -181,6 +194,7 @@ impl TaskControlBlock {
|
|||
pub fn getpid(&self) -> usize {
|
||||
self.pid.0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue