mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-23 01:46:24 +04:00
Merge branch 'dev' into main
This commit is contained in:
commit
0d9024b5bd
@ -12,7 +12,7 @@ const DL: u8 = 0x7fu8;
|
|||||||
const BS: u8 = 0x08u8;
|
const BS: u8 = 0x08u8;
|
||||||
|
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use user_lib::{fork, exec, waitpid, yield_};
|
use user_lib::{fork, exec, waitpid};
|
||||||
use user_lib::console::getchar;
|
use user_lib::console::getchar;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@ -36,18 +36,10 @@ pub fn main() -> i32 {
|
|||||||
}
|
}
|
||||||
unreachable!();
|
unreachable!();
|
||||||
} else {
|
} else {
|
||||||
let mut xstate: i32 = 0;
|
let mut exit_code: i32 = 0;
|
||||||
let mut exit_pid: isize;
|
let exit_pid = waitpid(pid as usize, &mut exit_code);
|
||||||
loop {
|
|
||||||
exit_pid = waitpid(pid as usize, &mut xstate);
|
|
||||||
if exit_pid == -1 {
|
|
||||||
yield_();
|
|
||||||
} else {
|
|
||||||
assert_eq!(pid, exit_pid);
|
assert_eq!(pid, exit_pid);
|
||||||
println!("Shell: Process {} exited with code {}", pid, xstate);
|
println!("Shell: Process {} exited with code {}", pid, exit_code);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
line.clear();
|
line.clear();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user