handle_handoff/handle_handoff.rs
1//! Passes a privately duplicated handle through a child-side protocol.
2
3#[cfg(windows)]
4fn main() -> std::io::Result<()> {
5 use std::fs::File;
6
7 use windows_spawn::Command;
8
9 let log = File::create("worker.log")?;
10 let mut command = Command::new("worker.exe");
11 command.arg("--log-handle").arg_handle(&log)?;
12
13 // arg_handle stored a private non-inheritable duplicate. The worker
14 // protocol parses the following decimal argument as its borrowed handle.
15 drop(log);
16 let status = command.status()?;
17 assert!(status.success());
18 Ok(())
19}
20
21#[cfg(not(windows))]
22fn main() {}