Skip to content

Commit e7dca8e

Browse files
committed
Ignore proc_thread_attributes if the system doesn't support it
1 parent bfbfc0b commit e7dca8e

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

library/std/src/sys/pal/windows/c.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,3 +607,34 @@ mod wship6 {
607607
}
608608
}
609609
}
610+
611+
#[cfg(target_vendor = "rust9x")]
612+
compat_fn_with_fallback! {
613+
pub static KERNEL32: &CStr = c"kernel32" => { load: false, unicows: false };
614+
// >= Vista / Server 2008
615+
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-initializeprocthreadattributelist
616+
pub fn InitializeProcThreadAttributeList(
617+
lpattributelist: LPPROC_THREAD_ATTRIBUTE_LIST,
618+
dwattributecount: u32,
619+
dwflags: u32,
620+
lpsize: *mut usize
621+
) -> BOOL {
622+
unimplemented!()
623+
}
624+
// >= Vista / Server 2008
625+
pub fn UpdateProcThreadAttribute(
626+
lpattributelist: LPPROC_THREAD_ATTRIBUTE_LIST,
627+
dwflags: u32,
628+
attribute: usize,
629+
lpvalue: *const core::ffi::c_void,
630+
cbsize: usize,
631+
lppreviousvalue: *mut core::ffi::c_void,
632+
lpreturnsize: *const usize
633+
) -> BOOL {
634+
unimplemented!()
635+
}
636+
// >= Vista / Server 2008
637+
pub fn DeleteProcThreadAttributeList(lpattributelist: LPPROC_THREAD_ATTRIBUTE_LIST) {
638+
unimplemented!()
639+
}
640+
}

library/std/src/sys/pal/windows/process.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,15 @@ impl Command {
358358
let mut proc_thread_attribute_list;
359359
let mut si_ex;
360360

361-
if !self.proc_thread_attributes.is_empty() {
361+
#[allow(unused)]
362+
let mut proc_thread_addributes_supported = true;
363+
#[cfg(target_vendor = "rust9x")]
364+
{
365+
proc_thread_addributes_supported =
366+
c::InitializeProcThreadAttributeList::available().is_some();
367+
}
368+
369+
if !self.proc_thread_attributes.is_empty() && proc_thread_addributes_supported {
362370
si.cb = mem::size_of::<c::STARTUPINFOEXW>() as u32;
363371
flags |= c::EXTENDED_STARTUPINFO_PRESENT;
364372

0 commit comments

Comments
 (0)