Skip to main content

suspended_inspection/
suspended_inspection.rs

1//! Inspects process and primary-thread handles before resuming the child.
2
3#[cfg(windows)]
4fn main() -> std::io::Result<()> {
5    use std::os::windows::io::AsHandle;
6
7    use windows_spawn::Command;
8
9    let mut command = Command::new(r"C:\Windows\System32\cmd.exe");
10    command.args(["/D", "/C", "exit /b 0"]);
11
12    let suspended = command.spawn_suspended()?;
13    println!("created suspended process {}", suspended.id());
14    let _process = suspended.as_handle();
15    let _primary_thread = suspended.primary_thread_handle();
16
17    let mut child = suspended.resume()?;
18    assert!(child.wait()?.success());
19    Ok(())
20}
21
22#[cfg(not(windows))]
23fn main() {}