Repository: rust
Issue: Tracking issue windows_process_extensions_cur_creation_flags
Labels: T-libs-api,C-tracking-issue,A-process

<!--
Thank you for creating a tracking issue!

Tracking issues are for tracking a feature from implementation to stabilization.

Make sure to include the relevant RFC for the feature if it has one.

If the new feature is small, it may be fine to skip the RFC process. In that
case, you can use use `issue = "none"` in your initial implementation PR. The
reviewer will ask you to open a tracking issue if they agree your feature can be
added without an RFC.
-->

Feature gate: `#![feature(windows_process_extensions_cur_creation_flags)]`

This is a tracking issue for a new `current_creation_flags(&self)` function on CommandExt for windows.

<!--
Include a short description of the feature.
-->
On windows, std currently has a [creation_flags](https://doc.rust-lang.org/std/os/windows/process/trait.CommandExt.html#tymethod.creation_flags) method on Commands to set creation flags. However, if a rust library needs to set a creation flag and then spawn/consume a process, it has no way of not stomping the pre-existing flags. For example:

```rs
// Consume a command in a library crate. We need to create the process suspended.
fn consume_command(c: std::process::Command) {
    const CREATE_SUSPENDED: u32 = 0x00000004;
    do_stuff(c.creation_flags(CREATE_SUSPENDED));
}
const CREATE_NO_WINDOW: u32 = 0x08000000;
// The creation_flags call in consume_command will overwrite the NO_WINDOW flag
consume_command(some_command.creation_flags(CREATE_NO_WINDOW));
```

It would be nice to have a method to get the current flags, so a library can OR the pre-existing flags to ensure it doesn't overwrite them accidentally.

### Public API

<!--
For most library features, it'd be useful to include a summarized version of the public API.
(E.g. just the public function signatures without their doc comments or implementation.)
-->

```rust
// std::process

pub trait CommandExt: Sealed {
    #[unstable(feature = "windows_process_extensions_cur_creation_flags", issue = "96723")]
    fn current_creation_flags(&self) -> u32;
}
```

### Steps / History

<!--
For larger features, more steps might be involved.
If the feature is changed later, please add those PRs here as well.
-->

- [x] Implementation: #...
- [ ] Final comment period (FCP)
- [ ] Stabilization PR

<!--
Once the feature has gone through a few release cycles and there are no
unresolved questions left, the feature might be ready for stabilization.

If this feature didn't go through the RFC process, a final comment period
(FCP) is always needed before stabilization. This works as follows:

A library API team member can kick off the stabilization process, at which point
the rfcbot will ask all the team members to verify they agree with
stabilization. Once enough members agree and there are no concerns, the final
comment period begins: this issue will be marked as such and will be listed
in the next This Week in Rust newsletter. If no blocking concerns are raised in
that period of 10 days, a stabilzation PR can be opened by anyone.
-->

### Unresolved Questions

<!--
Include any open questions that need to be answered before the feature can be
stabilised. If multiple (unrelated) big questions come up, it can be a good idea
to open a separate issue for each, to make it easier to keep track of the
discussions.

It's useful to link any relevant discussions and conclusions (whether on GitHub,
Zulip, or the internals forum) here.
-->

- None yet.