about summary refs log tree commit diff
path: root/library/std/src/sys/windows/process.rs
AgeCommit message (Collapse)AuthorLines
2024-01-11std: begin moving platform support modules into `pal`joboet-984/+0
2023-11-24Rollup merge of #118060 - ChrisDenton:abs-device-path, r=thomccMatthias Krüger-1/+1
Use an absolute path to the NUL device While a bare "NUL" *should* be redirected to the NUL device, especially in this simple case, let's be explicit that we aren't opening a file called "NUL" and instead open it directly. This will also set a good example for people copying std code. r? libs
2023-11-22x fmt library/stdChris Denton-3/+2
2023-11-22redundant_closureChris Denton-1/+1
2023-11-22unnecessary_castChris Denton-2/+2
casting to the same type is unnecessary
2023-11-22needless_borrows_for_generic_argsChris Denton-1/+1
the borrowed expression implements the required traits
2023-11-19Use an absolute path to the NUL deviceChris Denton-1/+1
While a bare "NUL" *should* be redirected to the NUL device, especially in this simple case, let's be explicit that we aren't opening a file called "NUL" and instead open it directly. This will also set a good example for people copying std code.
2023-10-06Remove libcChris Denton-3/+2
We don't use much libc on Windows.
2023-09-09Auto merge of #114590 - ijackson:stdio-stdio-2, r=dtolnaybors-10/+25
Allow redirecting subprocess stdout to our stderr etc. (redux) This is the code from #88561, tidied up, including review suggestions, and with the for-testing-only CI commit removed. FCP for the API completed in #88561. I have made a new MR to facilitate review. The discussion there is very cluttered and the branch is full of changes (in many cases as a result of changes to other Rust stdlib APIs since then). Assuming this MR is approvedl we should close that one. ### Reviewer doing a de novo review Just code review these four commits.. FCP discussion starts here: https://github.com/rust-lang/rust/pull/88561#issuecomment-1640527595 Portability tests: you can see that this branch works on Windows too by looking at the CI results in #88561, which has the same code changes as this branch but with an additional "DO NOT MERGE" commit to make the Windows tests run. ### Reviewer doing an incremental review from some version of #88561 Review the new commits since your last review. I haven't force pushed the branch there. git diff the two branches (eg `git diff 176886197d6..0842b69c219`). You'll see that the only difference is in gitlab CI files. You can also see that *this* MR doesn't touch those files.
2023-09-03Command::spawn: Fix STARTUPINFOW.cb being initialized with the address of ↵Fulgen301-1/+1
size_of
2023-09-01fix(std): Rename os_str_bytes to encoded_bytesEd Page-2/+2
2023-08-25Added option to set ProcThreadAttributes for Windows processesMichael van Straten-2/+110
This implements the ability to add arbitrary attributes to a command on Windows targets using a new `raw_attribute` method on the [`CommandExt`](https://doc.rust-lang.org/stable/std/os/windows/process/trait.CommandExt.html) trait. Setting these attributes provides extended configuration options for Windows processes. Co-authored-by: Tyler Ruckinger <t.ruckinger@gmail.com>
2023-08-08Rollup merge of #106425 - ijackson:exit-status-default, r=dtolnayMatthias Krüger-1/+1
Make ExitStatus implement Default And, necessarily, make it inhabited even on platforms without processes. I noticed while preparing https://github.com/rust-lang/rfcs/pull/3362 that there was no way for anyone to construct an `ExitStatus`. This would be insta-stable so needs an FCP.
2023-08-07impl Default for ExitStatusIan Jackson-1/+1
2023-08-07std::process (windows): Implement From<io::Stdout> etc. for imp::StdioIan Jackson-0/+14
This involves a new variant `imp;::Stdio::InheritSpecific`. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2023-08-07std::process (windows): refactor Stdio::to_handle slightlyIan Jackson-10/+11
We're going to want to reuse this bit of code.
2023-07-01Return `Ok` on kill if process has already exitedChris Denton-1/+10
2023-05-13refactor: Remove redundant, private OsStr::bytesEd Page-2/+2
2023-05-05Use new bindingsChris Denton-5/+5
2023-03-21Rollup merge of #96391 - ChrisDenton:command-non-verbatim, r=joshtriplettMatthias Krüger-8/+4
Windows: make `Command` prefer non-verbatim paths When spawning Commands, the path we use can end up being queried using `env::current_exe` (or the equivalent in other languages). Not all applications handle these paths properly therefore we should have a stronger preference for non-verbatim paths when spawning processes.
2022-12-11Implement blocking outputAyush Singh-0/+5
This allows decoupling `Command::spawn` and `Command::output`. This is useful for targets which do support launching programs in blocking mode but do not support multitasking (Eg: UEFI). This was originally conceived when working on https://github.com/rust-lang/rust/pull/100316 Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-12-06Don't set `STARTF_USESTDHANDLES` if none are setChris Denton-7/+15
2022-12-02Windows: make Command prefer non-verbatim pathsChris Denton-8/+4
When spawning Commands, the path we use can end up being queried using `env::current_exe` (or the equivalent in other languages). Not all applications handle these paths properly therefore we should have a stronger preference for non-verbatim paths when spawning processes.
2022-10-24Pass on null handle values to child processChris Denton-7/+5
2022-10-13std: use `sync::Mutex` for internal staticsjoboet-3/+3
2022-06-09Implement ExitCodeExt for WindowsAron Parker-0/+6
2022-05-17Revert "Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-se"Mark Rousskov-32/+6
This reverts commit ddb7fbe8434be481607ae199fe2aee976ee2fc2e, reversing changes made to baaa3b682986879c7784b5733ecea942e9ae7de3.
2022-05-11Rollup merge of #96861 - m-ou-se:std-use-prelude-2021, r=joshtriplettYuki Okushi-1/+0
Use Rust 2021 prelude in std itself.
2022-05-10Expose process main_thread_handle on Windowsunknown-7/+13
2022-05-09Use Rust 2021 prelude in std itself.Mara Bos-1/+0
2022-04-27Note the importance of using sync pipesChris Denton-1/+19
2022-04-26Windows: Make stdin pipes synchronousChris Denton-6/+14
Stdin pipes do not need to be used asynchronously within the standard library.
2022-04-25Auto merge of #95246 - ChrisDenton:command-args, r=joshtriplettbors-86/+30
Windows Command: Don't run batch files using verbatim paths Fixes #95178 Note that the first commit does some minor refactoring (moving command line argument building to args.rs). The actual changes are in the second.
2022-04-08Windows: Use a pipe relay for chaining pipesChris Denton-1/+7
2022-03-23Command: handle exe and batch files separatelyChris Denton-17/+25
2022-03-23Refactor: Move argument building into argsChris Denton-69/+5
2022-02-17Keep the path after `program_exists` succeedsChris Denton-22/+23
2022-02-17Use verbatim paths for `process::Command` if necessaryChris Denton-11/+21
2022-02-14Maintain broken symlink behaviour for the Windows exe resolverChris Denton-2/+17
2022-02-09Rollup merge of #93445 - yaahc:exitcode-constructor, r=dtolnayYuki Okushi-0/+6
Add From<u8> for ExitCode This should cover a mostly cross-platform subset of supported exit codes. We decided to stick with `u8` initially since its the common subset between all platforms that we support (excluding wasm which I think only works with `true` or `false`). Posix is supposed to take i32s, but in practice many unix platforms mask out all but the low 8 bits or in some cases the 8-15th bits. Windows takes a u32 instead of an i32. Bourne-compatible shells also report signals as exitcode 128 + `signal_no`, so there's some ambiguity there when returning exit codes > 127, but it is possible to disambiguate them on the other side so we decided against restricting the possible codes further than to `u8`. ## Related - Detailed analysis of exit code support on various platforms: https://internals.rust-lang.org/t/mini-pre-rfc-redesigning-process-exitstatus/5426 - https://github.com/rust-lang/rust/issues/48711 - https://github.com/rust-lang/rust/issues/43301 - https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Termination.2FExit.20Status.20Stabilization
2022-02-06Add From<u8> for ExitCodeJane Lusby-0/+6
This should cover a mostly cross-platform subset of supported exit codes.
2022-02-04Hide Repr details from io::Error, and rework `io::Error::new_const`.Thom Chiovoloni-4/+4
2022-01-03Explicitly pass `PATH` to the Windows exe resolverChris Denton-11/+20
2021-12-16Quote bat script command lineChris Denton-0/+16
2021-10-31 Windows: Resolve Command program without using the current directoryChris Denton-26/+141
2021-08-19Use the correct `into_*` on Windows to avoid dropping a stdio handle.Dan Gohman-2/+2
Use `into_raw_handle()` rather than `into_inner()` to completely consume a `Handle` without dropping its contained handle.
2021-08-19I/O safety.Dan Gohman-19/+22
Introduce `OwnedFd` and `BorrowedFd`, and the `AsFd` trait, and implementations of `AsFd`, `From<OwnedFd>` and `From<T> for OwnedFd` for relevant types, along with Windows counterparts for handles and sockets. Tracking issue: - <https://github.com/rust-lang/rust/issues/87074> RFC: - <https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md>
2021-08-08Fix Windows Command::env("PATH")Chris Denton-5/+24
2021-07-09Debug formatting of raw_arg()Kornel-2/+6
2021-07-09Unescaped command-line arguments for WindowsKornel-18/+51
Fixes #29494