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