-
Notifications
You must be signed in to change notification settings - Fork 20
Add ability to customize STARTUPINFO structure in Command API #562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
cc @ChrisDenton for Windows review. Doing a quick review of some of the flags in dwFlags, to figure out if we need to filter any of them out for safety, or add anything else to go with them:
Given all the above, it sounds like the only flags that a For the other flags:
All of those are optional; we should filter out those flags, but we don't have to add methods for them right away. Lastly, because there are so few flags that can be set this way and don't need separate setter methods, I wonder if it'd be more user-friendly to just directly provide setter methods for those specific flags, rather than having a single method that takes a combination of flags. For instance, we could have @ChrisDenton, @federico-terzi, thoughts? |
My only issue would be, as you say, safely exposing an option which later turns out to be unsafe. This happened with So I'm happy with either having an unsafe way to set |
Between those two options, I would favor adding safe methods for the known safe flags, and we can always add the unsafe mechanism later if we can't expose some piece of functionality in a safe way. |
Thank you for the great analysis! I think individual flags (eg. |
Could you please update the ACP with those APIs? |
We discussed this in today's @rust-lang/libs-api meeting and agreed that this should be individual flag methods. If you get a chance to update the ACP, we can then review and approve that ACP in a future meeting. |
Sorry for the radio silence! That's great, I'll make sure to update the ACP soon |
Sorry for the delay, I've updated the ACP with the methods as you suggested |
Thanks! We discussed this again in the @rust-lang/libs-api meeting and are happy to accept this. Feel free to open a tracking issue and open a PR to rust-lang/rust to add it as an unstable feature. |
Thank you, will do it soon! |
@Amanieu @joshtriplett Thank you for all the input! I've opened a tracking issue and PR: |
Discussion should continue in the tracking issue. |
Proposal
Problem statement
I need a way to customize the STARTUPINFO structure when spawning a new
Command
on WindowsMotivating examples or use cases
I'm working on a desktop application which needs to often spawn sub-processes as part of its regular operation. The
Command
API works well in general, but there's a problem: by default, on Windows every sub-process causes the parent window to display a "spinner" (aka feedback) cursor until the sub-process displays a window. This becomes problematic when the sub-processes are worker processes that will never display a window, as it makes the parent app appear unresponsive due to the spinning cursor.In Windows land, this is easily solvable by passing the
STARTF_FORCEOFFFEEDBACK
flag to theSTARTUPINFO
struct, which is then passed to theCreateProcessW
(see SO question)Unfortunately, while the Command API exposes a
creation_flags
parameter, this only influences theCreateProcessW
flags, not theSTARTUPINFO
flags.Solution sketch
Ideally, the Command API should expose some methods to configure the
startupinfo_flags
individually. After a discussion, we propose to expose the following methods:The
STARTUPINFO
struct accepts also other flags, but their use is less straightforward as they have side-effects and relationships with other fields, so they can't be changed in isolation (see follow-up comment from @joshtriplett for more details).Alternatives
For this specific problem, I'm using a workaround to post a dummy message on the sub-process (see SO question). This unfortunately still causes the loading cursor to appear for a fraction of a second, so it's not a solution.
Links and related work
I believe this would be a great addition to the standard library, as it's similar to the existing
creation_flags
argumentThe text was updated successfully, but these errors were encountered: