Function wait_parent

Source
pub fn wait_parent() -> Option<ExitStatus>
Examples found in repository?
examples/single.rs (line 7)
1fn main() {
2    match std::env::args().nth(1).as_deref() {
3        Some("--wait-parent") => {
4            // std::thread::sleep(std::time::Duration::from_secs(5));
5
6            println!("Waiting parent...");
7            let status = wait_parent::wait_parent();
8
9            println!("Parent exited with {:?}", status);
10            // std::fs::write("status.txt", format!("{:?}", status)).unwrap();
11
12            const STATUS_CONTROL_C_EXIT: i32 = 0xC000013Au32 as i32;
13            match status.and_then(|s| s.code()) {
14                Some(0 | STATUS_CONTROL_C_EXIT) => (),
15                Some(_) => {
16                    // std::process::Command::new(std::env::current_exe().unwrap())
17                    //     .spawn()
18                    //     .unwrap();
19
20                    std::thread::sleep(std::time::Duration::from_secs(5));
21                    println!("Child exiting...");
22                }
23                None => (),
24            }
25        }
26        Some(_) => unreachable!(),
27        None => {
28            println!("Spwaning child...");
29            std::process::Command::new(std::env::current_exe().unwrap())
30                .arg("--wait-parent")
31                .spawn()
32                .unwrap();
33
34            std::thread::sleep(std::time::Duration::from_secs(3));
35
36            // panic!();
37        }
38    }
39}