about summary refs log tree commit diff
path: root/library/std/src/process.rs
AgeCommit message (Collapse)AuthorLines
2024-05-19Rollup merge of #123709 - tgross35:windows-cmd-docs-update, r=ChrisDentonMichael Goulet-21/+27
Update documentation related to the recent cmd.exe fix Fix some grammar nits, change `bat` (extension) -> `batch` (file), and make line wrapping more consistent.
2024-05-04Rollup merge of #122441 - a1phyr:improve_read_impls, r=ChrisDentonMatthias Krüger-0/+4
Improve several `Read` implementations - `read_to_end` and `read_to_string` for `Cursor` - Error on OOM in `read_to_string` of `&[u8]` and `VecDeque<u8>` - Avoid making the slices contiguous in `VecDeque::read_to_string` - ~`read_exact` and (unstable) `read_buf_exact` for `Take`~ - ~`read_buf` for `UnixStream` and `&UnixStream`~ (moved to #123084) - `read_to_end` for `ChildStdErr`
2024-04-22Stabilize generic `NonZero`.Markus Reiter-1/+2
2024-04-12Improve several `Read` implementationsBenoît du Garreau-0/+4
2024-04-09Update documentation related to the recent cmd.exe fixTrevor Gross-21/+27
Fix some grammar nits, change `bat` (extension) -> `batch` (file), and make line wrapping more consistent.
2024-04-09Document Windows argument splittingChris Denton-0/+79
2024-02-22Use generic `NonZero` everywhere in `std`.Markus Reiter-7/+7
2024-02-13Fix incorrect use of `compile_fail`Noah Lev-3/+3
`compile_fail` should only be used when the code is meant to show what *not* to do. In other words, there should be a fundamental flaw in the code. However, in this case, the example is just incomplete, so we should use `ignore` to avoid confusing readers.
2023-12-15Cfg remove lang items in doctestCameron Steffen-1/+1
2023-11-22add missing period in `std::process::Command` docsMax Heller-1/+1
2023-11-15Substitute version placeholdersMark Rousskov-1/+1
2023-10-15Deduplicate std::process Default impl feature namesDavid Tolnay-2/+2
error[E0711]: feature `process-exitcode-default` is declared stable since 1.74.0-beta.1, but was previously declared stable since 1.73.0 --> library/std/src/process.rs:1964:1 | 1964 | #[stable(feature = "process-exitcode-default", since = "CURRENT_RUSTC_VERSION")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-08-07impl Default for ExitCodeIan Jackson-0/+8
As suggested here https://github.com/rust-lang/rust/pull/106425#issuecomment-1382952598
2023-10-14Auto merge of #116407 - Mark-Simulacrum:bootstrap-bump, r=onur-ozkanbors-2/+2
Bump bootstrap compiler to just-released beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2023-10-05Add more diagnostic items for clippyJason Newcomb-0/+2
2023-10-04Rollup merge of #116146 - Milo123459:milo/clarify-arg-documentation, r=thomccMatthias Krüger-2/+2
Clarify `arg` and `args` documentation Fixes #95400
2023-10-03Bump version placeholdersMark Rousskov-2/+2
2023-09-28Auto merge of #114428 - ChaiTRex:master, r=dtolnaybors-3/+3
Convert `Into<ExitStatus> for ExitStatusError` to `From<ExitStatusError> for ExitStatus` in `std::process` Implementing suggestion from https://github.com/rust-lang/rust/issues/84908#issuecomment-912352902: > I believe the impl on ExitStatusError should be > > ```rust > impl From<ExitStatusError> for ExitStatus > ``` > > rather than > > ```rust > impl Into<ExitStatus> for ExitStatusError > ``` > > (there is generally never anything implemented as `Into` first, because implementing `From` reflexively provides `Into`)
2023-09-28Rollup merge of #115535 - tshepang:patch-2, r=dtolnayMatthias Krüger-71/+69
format doc-comment code examples in std::process
2023-09-25update other placeMilo-1/+1
2023-09-25clarify documentation about variable substituionMilo-1/+1
2023-09-22Rollup merge of #114379 - RalfJung:command-removed-env-vars, r=m-ou-seMatthias Krüger-1/+1
Command: also print removed env vars There is no real shell syntax for unsetting an env var so easily, so we have to make one up. But we already do that for showing the 'program' name so I hope that's okay here, too. No strong opinion on what that should look like, I went with `unset(VAR_NAME)` for now.
2023-09-19Auto merge of #104101 - betrusted-io:xous-libstd-initial, r=bjorn3bors-1/+1
Add initial libstd support for Xous This patchset adds some minimal support to the tier-3 target `riscv32imac-unknown-xous-elf`. The following features are supported: * alloc * thread creation and joining * thread sleeping * thread_local * panic_abort * mutex * condvar * stdout Additionally, internal support for the various Xous primitives surrounding IPC have been added as part of the Xous FFI. These may be exposed as part of `std::os::xous::ffi` in the future, however for now they are not public. This represents the minimum viable product. A future patchset will add support for networking and filesystem support.
2023-09-09Auto merge of #114590 - ijackson:stdio-stdio-2, r=dtolnaybors-0/+60
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-04"what would rustfmt do"Tshepang Mbambo-71/+69
2023-08-24fix a typo in env_clear docsRalf Jung-1/+1
2023-08-22std: process: skip tests on xousSean Cross-1/+1
Xous does not yet support spawning processes. Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22Replace version placeholders with 1.73.0Mark Rousskov-1/+1
2023-08-15Document Default for ExitStatusIan Jackson-1/+10
This lets us put a version on the impl, too.
2023-08-10Rollup merge of #114194 - thomcc:flushinline, r=cuviperMichael Goulet-0/+2
Inline trivial (noop) flush calls At work I noticed that `writer.flush()?` didn't get optimized away in cases where the flush is obviously a no-op, which I had expected (well, desired). I went through and added `#[inline]` to a bunch of cases that were obviously noops, or delegated to ones that were obviously noops. I omitted platforms I don't have access to (some tier3). I didn't do this very scientifically, in cases where it was non-obvious I left `#[inline]` off.
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: impl From<io::Stdout> (etc.) for StdioIan Jackson-0/+60
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2023-08-03Convert `Into<ExitStatus> for ExitStatusError` to `From<ExitStatusError> for ↵Chai T. Rex-3/+3
ExitStatus` in `std::process`
2023-07-28inline trivial (noop) flush callsThom Chiovoloni-0/+2
2023-07-18Update documentation for std::process::Command's new methodAleksandr Kovalev-0/+8
In the current documentation, it's not specified that when creating a Command, the .exe extension can be omitted for Windows executables. However, for other types of executable files like .bat or .cmd, the complete filename including the extension must be provided. I encountered it by noticing that `Command::new("wt").spawn().unwrap()` succeeds on my machine while `Command::new("code").spawn().unwrap()` panics. Turns out VS Code's entrypoint is .cmd file. `resolve_exe` method mentions this behaviour in a comment[1], but it makes sense to mention it at more visible place. I've added this clarification to the documentation, which should make it more accurate and helpful for Rust developers working on the Windows platform. [1] https://github.com/rust-lang/rust/blob/e7fda447e7d05b6ca431fc8fe8f489b1fda810bc/library/std/src/sys/windows/process.rs#L425
2023-07-01Return `Ok` on kill if process has already exitedChris Denton-3/+3
2023-05-08Auto merge of #106621 - ozkanonur:enable-elided-lifetimes-for-doctests, ↵bors-1/+1
r=Mark-Simulacrum enable `rust_2018_idioms` lint group for doctests With this change, `rust_2018_idioms` lint group will be enabled for compiler/libstd doctests. Resolves #106086 Resolves #99144 Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-05-07enable `rust_2018_idioms` for doctestsozkanonur-1/+1
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-05-01Inline AsInner implementationsKonrad Borowski-0/+8
2023-04-14Rollup merge of #109272 - schneems:schneems/add-docs-to-command-env-methods, ↵Matthias Krüger-15/+61
r=Amanieu Add Command environment variable inheritance docs The interaction between the environment variable methods can be confusing. Specifically `env_clear` and `remove_env` have a side effects not mentioned: they disable inheriting environment variables from the parent process. I wanted to fully document this behavior as well as explain relevant edge cases in each of the `Command` env methods. This is further confused by the return of `get_envs` which will return key/None if `remove_env` has been used, but an empty iterator if `env_clear` has been called. Or a non-empty iterator if `env_clear` was called and later explicit mappings are added. Currently there is no way (that I'm able to find) of observing whether or not the internal `env_clear=true` been toggled on the `Command` struct via its public API. Ultimately environment variable mappings can be in one of several states: - Explicitly set value (via `envs` / `env`) will take precedence over parent mapping - Not explicitly set, will inherit mapping from parent - Explicitly removed via `remove_env`, this single mapping will not inherit from parent - Implicitly removed via `env_clear`, no mappings will inherit from parent I tried to represent this in the relevant sections of the docs. This is my second-ever doc PR (whoop!). I'm happy to take specific or general doc feedback. Also happy to explain the logic behind any changes or additions I made.
2023-04-09Apply suggestions from code review Richard Schneeman-1/+1
Fixes documentation. I wrote `env_clear` when I meant `env_remove`. Good catch. Co-authored-by: Josh Stone <cuviper@gmail.com>
2023-03-17Add Command environment variable inheritance docsschneems-15/+61
The interaction between the environment variable methods can be confusing. Specifically `env_clear` and `remove_env` have a side effects not mentioned: they disable inheriting environment variables from the parent process. I wanted to fully document this behavior as well as explain relevant edge cases in each of the `Command` env methods. This is further confused by the return of `get_envs` which will return key/None if `remove_env` has been used, but an empty iterator if `env_clear` has been called. Or a non-empty iterator if `env_clear` was called and later explicit mappings are added. Currently there is no way (that I'm able to find) of observing whether or not the internal `env_clear=true` been toggled on the `Command` struct via its public API. Ultimately environment variable mappings can be in one of several states: - Explicitly set value (via `envs` / `env`) will take precedence over parent mapping - Not explicitly set, will inherit mapping from parent - Explicitly removed via `remove_env`, this single mapping will not inherit from parent - Implicitly removed via `env_clear`, no mappings will inherit from parent I tried to represent this in the relevant sections of the docs. This is my second ever doc PR (whoop!). I'm happy to take specific or general doc feedback. Also happy to explain the logic behind any changes or additions I made.
2023-03-06Implement read_buf for a few more typesTomasz Miąsko-1/+9
Implement read_buf for TcpStream, Stdin, StdinLock, ChildStdout, ChildStderr (and internally for AnonPipe, Handle, Socket), so that it skips buffer initialization. The other provided methods like read_to_string and read_to_end are implemented in terms of read_buf and so benefit from the optimization as well. This commit also implements read_vectored and is_read_vectored where applicable.
2023-03-03Match unmatched backticks in library/est31-1/+1
2022-12-28delete more `cfg(bootstrap)`Lukas Markeffsky-12/+5
2022-12-27More verbose `Debug` implementation of `std::process:Command`kraktus-0/+9
based on commit: https://github.com/zackmdavis/rust/commit/ccc019aabfdd550944c049625e66c92c815ea1d0 from https://github.com/zackmdavis close https://github.com/rust-lang/rust/issues/42200 Add env variables and cwd to the shell-like debug output. Also use the alternate syntax to display a more verbose display, while not showing internal fields and hiding fields when they have their default value.
2022-12-11Implement blocking outputAyush Singh-4/+2
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-08Add read_to_end for AnonPipeAyush Singh-0/+4
Add `read_to_end` method for `sys::{target}::pipe::AnonPipe`. This allows having a more optimized version of `read_to_end` for ChildStdout. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-10-17Make diagnostic for unsatisfied Termination bounds more preciseLeón Orell Valerian Liehr-2/+10