Implement many process syscalls.
This commit is contained in:
parent
e56ea17566
commit
8fbadfc951
20 changed files with 383 additions and 88 deletions
|
@ -12,7 +12,7 @@ const DL: u8 = 0x7fu8;
|
|||
const BS: u8 = 0x08u8;
|
||||
|
||||
use alloc::string::String;
|
||||
use user_lib::{fork, exec, wait};
|
||||
use user_lib::{fork, exec, waitpid, yield_};
|
||||
use user_lib::console::getchar;
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -37,8 +37,17 @@ pub fn main() -> i32 {
|
|||
unreachable!();
|
||||
} else {
|
||||
let mut xstate: i32 = 0;
|
||||
wait(&mut xstate);
|
||||
println!("Shell: Process {} exited with code {}", pid, xstate);
|
||||
let mut exit_pid: isize = 0;
|
||||
loop {
|
||||
exit_pid = waitpid(pid as usize, &mut xstate);
|
||||
if exit_pid == -1 {
|
||||
yield_();
|
||||
} else {
|
||||
assert_eq!(pid, exit_pid);
|
||||
println!("Shell: Process {} exited with code {}", pid, xstate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
line.clear();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue