| 8 | |
| 9 | #[no_mangle] |
| 10 | pub fn main() -> i32 { |
| 11 | assert_eq!(wait(&mut 0i32), -1); |
| 12 | println!("sys_wait without child process test passed!"); |
| 13 | println!("parent start, pid = {}!", getpid()); |
| 14 | let pid = fork(); |
| 15 | if pid == 0 { |
| 16 | // child process |
| 17 | println!("hello child process!"); |
| 18 | 100 |
| 19 | } else { |
| 20 | // parent process |
| 21 | let mut exit_code: i32 = 0; |
| 22 | println!("ready waiting on parent process!"); |
| 23 | assert_eq!(pid, wait(&mut exit_code)); |
| 24 | assert_eq!(exit_code, 100); |
| 25 | println!("child process pid = {}, exit code = {}", pid, exit_code); |
| 26 | 0 |
| 27 | } |
| 28 | } |