Skip to content

Commit 5bd4988

Browse files
committed
Ignore proc_thread_attributes if the system doesn't support it
1 parent 015ec65 commit 5bd4988

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
@@ -594,3 +594,34 @@ mod wship6 {
594594
}
595595
}
596596
}
597+
598+
#[cfg(target_vendor = "rust9x")]
599+
compat_fn_with_fallback! {
600+
pub static KERNEL32: &CStr = c"kernel32" => { load: false, unicows: false };
601+
// >= Vista / Server 2008
602+
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-initializeprocthreadattributelist
603+
pub fn InitializeProcThreadAttributeList(
604+
lpattributelist: LPPROC_THREAD_ATTRIBUTE_LIST,
605+
dwattributecount: u32,
606+
dwflags: u32,
607+
lpsize: *mut usize
608+
) -> BOOL {
609+
unimplemented!()
610+
}
611+
// >= Vista / Server 2008
612+
pub fn UpdateProcThreadAttribute(
613+
lpattributelist: LPPROC_THREAD_ATTRIBUTE_LIST,
614+
dwflags: u32,
615+
attribute: usize,
616+
lpvalue: *const core::ffi::c_void,
617+
cbsize: usize,
618+
lppreviousvalue: *mut core::ffi::c_void,
619+
lpreturnsize: *const usize
620+
) -> BOOL {
621+
unimplemented!()
622+
}
623+
// >= Vista / Server 2008
624+
pub fn DeleteProcThreadAttributeList(lpattributelist: LPPROC_THREAD_ATTRIBUTE_LIST) {
625+
unimplemented!()
626+
}
627+
}

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)