1 #![warn(rust_2018_idioms)]
2 #![cfg(feature = "full")]
3 #![cfg(windows)]
4 #![cfg(not(miri))]
5 
6 use tokio::process::Command;
7 use windows_sys::Win32::System::Threading::GetProcessId;
8 
9 #[tokio::test]
obtain_raw_handle()10 async fn obtain_raw_handle() {
11     let mut cmd = Command::new("cmd");
12     cmd.kill_on_drop(true);
13     cmd.arg("/c");
14     cmd.arg("pause");
15 
16     let child = cmd.spawn().unwrap();
17 
18     let orig_id = child.id().expect("missing id");
19     assert!(orig_id > 0);
20 
21     let handle = child.raw_handle().expect("process stopped");
22     let handled_id = unsafe { GetProcessId(handle as _) };
23     assert_eq!(handled_id, orig_id);
24 }
25