1use std::{thread::sleep, time::Duration};
2
3use privesc::PrivilegedCommand;
4
5fn main() {
6 let mut child = PrivilegedCommand::new("sleep").arg("2").spawn().unwrap();
8
9 if let Some(id) = child.id() {
10 println!("Spawned process with ID: {id}");
11 }
12
13 println!("Doing other work while process runs...");
15
16 sleep(Duration::from_secs(1));
17
18 match child.try_wait().unwrap() {
20 Some(status) => println!("Process already finished with: {status}"),
21 None => println!("Process still running..."),
22 }
23
24 println!("Waiting for process to finish...");
26 let output = child.wait().unwrap();
27
28 println!("Exit status: {}", output.status);
29}