about summary refs log tree commit diff
path: root/library/std/src/process
diff options
context:
space:
mode:
authorMichael van Straten <michael@vanstraten.de>2024-04-07 21:08:37 +0200
committerMichael van Straten <michael@vanstraten.de>2024-11-30 10:17:59 +0100
commitf371952cdeee32ce8fb3e859e5a1fd05a1e750aa (patch)
treec50182010df43f4b257c9e9a61c0943d8777dcda /library/std/src/process
parentd6f88291f3ce96375683acc62d54710add042f98 (diff)
downloadrust-f371952cdeee32ce8fb3e859e5a1fd05a1e750aa.tar.gz
rust-f371952cdeee32ce8fb3e859e5a1fd05a1e750aa.zip
Abstract `ProcThreadAttributeList` into its own struct
Diffstat (limited to 'library/std/src/process')
-rw-r--r--library/std/src/process/tests.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/library/std/src/process/tests.rs b/library/std/src/process/tests.rs
index fb0b495961c..e8cbfe337bc 100644
--- a/library/std/src/process/tests.rs
+++ b/library/std/src/process/tests.rs
@@ -450,7 +450,7 @@ fn test_creation_flags() {
 fn test_proc_thread_attributes() {
     use crate::mem;
     use crate::os::windows::io::AsRawHandle;
-    use crate::os::windows::process::CommandExt;
+    use crate::os::windows::process::{CommandExt, ProcThreadAttributeList};
     use crate::sys::c::{BOOL, CloseHandle, HANDLE};
     use crate::sys::cvt;
 
@@ -490,12 +490,14 @@ fn test_proc_thread_attributes() {
 
     let mut child_cmd = Command::new("cmd");
 
-    unsafe {
-        child_cmd
-            .raw_attribute(PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, parent.0.as_raw_handle() as isize);
-    }
+    let parent_process_handle = parent.0.as_raw_handle();
+
+    let mut attribute_list = ProcThreadAttributeList::build()
+        .attribute(PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, &parent_process_handle)
+        .finish()
+        .unwrap();
 
-    let child = ProcessDropGuard(child_cmd.spawn().unwrap());
+    let child = ProcessDropGuard(child_cmd.spawn_with_attributes(&mut attribute_list).unwrap());
 
     let h_snapshot = unsafe { CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) };