Add ability to customize STARTUPINFO structure in std Command API

Hi,

I'm facing a tricky limitation of the current stdlib Command API on Windows: I need to customize the flags of the STARTUPINFO struct passed to the CreateProcessW call.

The use-case is being able to pass the STARTF_FORCEOFFFEEDBACK flag, which is necessary to avoid having Windows show a loading spinner every time a new sub-process is launched.

Having an Ext API like creation_flags that applies to the STARTUPINFO flags would be great.

How can I propose to expose this API? Sorry if I missed something obvious, it's my first time posting on this forum.

There's a CommandExt trait for Windows, that extends the Command type (you just need to import the trait under #[cfg(target_os = "windows")] or, I think, #[cfg(windows)]).

Is the method creation_flags enough for your use case? (you need to find out which bit the STARTF_FORCEOFFFEEDBACK flag sets - per the table here it's 0x00000080)

Hey @dlight ,

thank you for the answer! Unfortunately, creation_flags refer to the dwCreationFlags of the CreateProcessW method, whereas STARTF_FORCEOFFFEEDBACK can only be passed as the dwFlags field of STARTUPINFO, which is then passed to CreateProcessW.

I went through the stdlib Command source code and I couldn't find a way to customize the STARTUPINFO struct flags, but maybe I'm missing something...

It would probably be appropriate to add another method to CommandExt to set dwFlags. One thing to check, though, is whether any of the other bits of dwFlags can cause undefined behavior in the calling process. In that case, the method must either be unsafe or filter the flags.

The process for adding features is documented here: Feature lifecycle - Standard library developers Guide. In this case, since implementing the feature is easy, sending a PR without creating an API Change Proposal first would be a reasonable course of action.

2 Likes

Thank you @kpreid! I'll try doing as you suggested

While adding the feature is easy, I do expect that because of the possibility of needing to review and filter the flags, it'd make sense to file an ACP. That'll give a good opportunity for libs-api, as well as Windows experts in the project, to carefully consider it.

Thank you @josh, I'll try to file an ACP then

For future reference, I filed an ACP: Add ability to customize STARTUPINFO structure in Command API · Issue #562 · rust-lang/libs-team · GitHub

2 Likes