mirror of
https://github.com/LearningOS/rust-based-os-comp2022.git
synced 2026-02-12 22:55:36 +08:00
29 lines
587 B
Rust
29 lines
587 B
Rust
#![no_std]
|
|
#![no_main]
|
|
|
|
#[macro_use]
|
|
extern crate user_lib;
|
|
|
|
use user_lib::{exec, fork, wait, yield_};
|
|
|
|
#[no_mangle]
|
|
fn main() -> i32 {
|
|
if fork() == 0 {
|
|
exec("ch5b_user_shell\0", &[0 as *const u8]);
|
|
} else {
|
|
loop {
|
|
let mut exit_code: i32 = 0;
|
|
let pid = wait(&mut exit_code);
|
|
if pid == -1 {
|
|
yield_();
|
|
continue;
|
|
}
|
|
println!(
|
|
"[initproc] Released a zombie process, pid={}, exit_code={}",
|
|
pid, exit_code,
|
|
);
|
|
}
|
|
}
|
|
0
|
|
}
|