about summary refs log tree commit diff
path: root/src/libstd/process.rs
AgeCommit message (Collapse)AuthorLines
2017-07-28rustbuild: Use Cargo's "target runner"Alex Crichton-2/+13
This commit leverages a relatively new feature in Cargo to execute cross-compiled tests, the `target.$target.runner` configuration. We configure it through environment variables in rustbuild and this avoids the need for us to locate and run tests after-the-fact, instead relying on Cargo to do all that execution for us.
2017-07-21Add a missing verb to the description of std::process::ExitStatus::success().Petr Zemek-2/+2
"Signal termination not considered" -> "Signal termination is not considered" The first line of the description was rewrapped so it fits into 80 characters.
2017-06-24Stabilize Command::envsSteven Fackler-3/+1
Closes #38526
2017-06-23Removed as many "```ignore" as possible.kennytm-2/+6
Replaced by adding extra imports, adding hidden code (`# ...`), modifying examples to be runnable (sorry Homura), specifying non-Rust code, and converting to should_panic, no_run, or compile_fail. Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-20Add `Read::initializer`.Steven Fackler-5/+7
This is an API that allows types to indicate that they can be passed buffers of uninitialized memory which can improve performance.
2017-06-06Add conversions from File and Child* handles to StdioJosh Stone-6/+35
`Stdio` now implements `From<ChildStdin>`, `From<ChildStdout>`, `From<ChildStderr>`, and `From<File>`. The `Command::stdin`/`stdout`/`stderr` methods now take any type that implements `Into<Stdio>`. This makes it much easier to write shell-like command chains, piping to one another and redirecting to and from files. Otherwise one would need to use the unsafe and OS-specific `from_raw_fd` or `from_raw_handle`.
2017-05-21Auto merge of #41904 - sfackler:1.18-stabilization, r=alexcrichtonbors-3/+1
Stabilize library features for 1.18.0 Closes #38863 Closes #38980 Closes #38903 Closes #36648 r? @alexcrichton @rust-lang/libs
2017-05-20Stabilize library features for 1.18.0Steven Fackler-3/+1
Closes #38863 Closes #38980 Closes #38903 Closes #36648
2017-05-18Add documentation for `ExitStatus`Michael Kohl-0/+23
As requested in #29370.
2017-05-03Update ChildStdin/ChildStdout docs to be clearerMichael Gattozzi-4/+6
2017-05-01Fix incorrect hex value in doc comment example.Corey Farwell-1/+1
2017-04-20Rollup merge of #40812 - mgattozzi:ChildDocs, r=steveklabnikCorey Farwell-11/+9
Update `Child` docs to not have a note section In #29370 it's noted that for "the Note shouldn't be one, and should come before the examples." This commit changes the positioning of the section and removes wording that said take note in order for it to flow better with the surrounding text and it's new position.
2017-04-19Fix link for waitMichael Gattozzi-1/+1
2017-04-09Auto merge of #40829 - mgattozzi:ChildStderr, r=steveklabnikbors-2/+3
Update ChildStderr docs to be clearer Before the docs only had a line about where it was found and that it was a handle to stderr. This commit changes it so that the summary second line is removed and that it's a bit clearer about what can be done with it. Part of #29370
2017-04-06Update process.rsraph-3/+2
2017-04-05Add example to std::process::abortraph-0/+22
This is a second (2/3?) step in order to complete this issue: https://github.com/rust-lang/rust/issues/29370 I submitted this PR with the help of @steveklabnik again. Thanks to him! More info here: https://github.com/rust-lang/rust/issues/29370#issuecomment-290653877
2017-04-04Change docs to follow review requestsMichael Gattozzi-3/+3
2017-03-30Update process.rsraph-1/+1
2017-03-29Removing trailing spacesraph-3/+3
2017-03-29adding ///raph-0/+1
2017-03-29Add example to std::process::abortraph-0/+13
2017-03-25Update ChildStderr docs to be clearerMichael Gattozzi-2/+3
Before the docs only had a line about where it was found and that it was a handle to stderr. This commit changes it so that the summary second line is removed and that it's a bit clearer about what can be done with it. Part of \#29370
2017-03-25Remove extra wait from Child docsMichael Gattozzi-1/+1
2017-03-24Update `Child` docs to not have a note sectionMichael Gattozzi-11/+9
In #29370 it's noted that for "the Note shouldn't be one, and should come before the examples." This commit changes the positioning of the section and removes wording that said take note in order for it to flow better with the surrounding text and it's new position.
2017-03-24Add a missing feature attribute to the example for ↵Petr Zemek-0/+2
std::process::Command::envs(). The person who originally wrote the example forgot to include this attribute. This caused Travis CI to fail on commit 9b0a4a4e97 (#40794), which just fixed formatting in the description of std::process::Command::envs().
2017-03-24Fix formatting in the docs for std::process::Command::envs().Petr Zemek-0/+1
An empty line between the "Basic usage:" text and the example is required to properly format the code. Without the empty line, the example is not formatted as code.
2017-03-20Rollup merge of #40312 - jdhorwitz:papercut, r=steveklabnikCorey Farwell-0/+21
Papercut r? @steveklabnik
2017-03-17Stabilize process_abort feature, closes #37838Aaron Turon-1/+1
2017-03-09Removed RustFMT changesJoshua Horwitz-0/+21
2017-02-27Example for how to provide stdin using std::process::CommandRobin Stocker-0/+25
Spawning a child process and writing to its stdin is a bit tricky due to `as_mut` and having to use a limited borrow. An example for this might help newer users.
2017-02-06make Child::try_wait return io::Result<Option<ExitStatus>>Jack O'Connor-8/+7
This is much nicer for callers who want to short-circuit real I/O errors with `?`, because they can write this if let Some(status) = foo.try_wait()? { ... } else { ... } instead of this match foo.try_wait() { Ok(status) => { ... } Err(err) if err.kind() == io::ErrorKind::WouldBlock => { ... } Err(err) => return Err(err), } The original design of `try_wait` was patterned after the `Read` and `Write` traits, which support both blocking and non-blocking implementations in a single API. But since `try_wait` is never blocking, it makes sense to optimize for the non-blocking case. Tracking issue: https://github.com/rust-lang/rust/issues/38903
2017-02-05Rollup merge of #39393 - ollie27:stab_impls, r=alexcrichtonCorey Farwell-5/+5
Fix a few impl stability attributes The versions show up in rustdoc.
2017-02-05Rollup merge of #38518 - nagisa:exec-doc, r=alexcrichtonCorey Farwell-2/+19
Expand documentation of process::exit and exec Show a conventional way to use process::exit when destructors are considered important and also mention that the same caveats wrt destructors apply to exec as well.
2017-01-29Fix a few impl stability attributesOliver Middleton-5/+5
The versions show up in rustdoc.
2017-01-25Auto merge of #38856 - zackw:process-envs, r=aturonbors-1/+36
Add std::process::Command::envs() `Command::envs()` adds a vector of key-value pairs to the child process environment all at once. Suggested in #38526. This is not fully baked and frankly I'm not sure it even _works_, but I need some help finishing it up, and this is the simplest way to show you what I've got. The problems I know exist and don't know how to solve, from most to least important, are: * [ ] I don't know if the type signature of the new function is correct. * [x] The new test might not be getting run. I didn't see it go by in the output of `x.py test src/libstd --stage 1`. * [x] The tidy check says ``process.rs:402: different `since` than before`` which I don't know what it means. r? @brson
2017-01-21Generalize envs() and args() to iterators.Zack Weinberg-6/+9
* Command::envs() now takes anything that is IntoIterator<Item=(K, V)> where both K and V are AsRef<OsStr>. * Since we're not 100% sure that's the right signature, envs() is now marked unstable. (You can use envs() with HashMap<str, str> but not Vec<(str, str)>, for instance.) * Update the test to match. * By analogy, args() now takes any IntoIterator<Item=S>, S: AsRef<OsStr>. This should be uncontroversial.
2017-01-19Expand documentation of process::exit and execSimonas Kazlauskas-2/+19
Show a conventional way to use process::exit when destructors are considered important and also mention that the same caveats wrt destructors apply to exec as well.
2017-01-10Fixes:Zack Weinberg-1/+1
* give the new feature its own feature tag * correct a lifetime problem in the test * use .output() instead of .spawn() in the test so that output is actually collected * correct the same error in the test whose skeleton I cribbed
2017-01-09Auto merge of #38866 - alexcrichton:try-wait, r=aturonbors-0/+42
std: Add a nonblocking `Child::try_wait` method This commit adds a new method to the `Child` type in the `std::process` module called `try_wait`. This method is the same as `wait` except that it will not block the calling thread and instead only attempt to collect the exit status. On Unix this means that we call `waitpid` with the `WNOHANG` flag and on Windows it just means that we pass a 0 timeout to `WaitForSingleObject`. Currently it's possible to build this method out of tree, but it's unfortunately tricky to do so. Specifically on Unix you essentially lose ownership of the pid for the process once a call to `waitpid` has succeeded. Although `Child` tracks this state internally to be resilient to multiple calls to `wait` or a `kill` after a successful wait, if the child is waited on externally then the state inside of `Child` is not updated. This means that external implementations of this method must be extra careful to essentially not use a `Child`'s methods after a call to `waitpid` has succeeded (even in a nonblocking fashion). By adding this functionality to the standard library it should help canonicalize these external implementations and ensure they can continue to robustly reuse the `Child` type from the standard library without worrying about pid ownership.
2017-01-06std: Add a nonblocking `Child::try_wait` methodAlex Crichton-0/+42
This commit adds a new method to the `Child` type in the `std::process` module called `try_wait`. This method is the same as `wait` except that it will not block the calling thread and instead only attempt to collect the exit status. On Unix this means that we call `waitpid` with the `WNOHANG` flag and on Windows it just means that we pass a 0 timeout to `WaitForSingleObject`. Currently it's possible to build this method out of tree, but it's unfortunately tricky to do so. Specifically on Unix you essentially lose ownership of the pid for the process once a call to `waitpid` has succeeded. Although `Child` tracks this state internally to be resilient to multiple calls to `wait` or a `kill` after a successful wait, if the child is waited on externally then the state inside of `Child` is not updated. This means that external implementations of this method must be extra careful to essentially not use a `Child`'s methods after a call to `waitpid` has succeeded (even in a nonblocking fashion). By adding this functionality to the standard library it should help canonicalize these external implementations and ensure they can continue to robustly reuse the `Child` type from the standard library without worrying about pid ownership.
2017-01-05Add std::process::Command::envs()Zack Weinberg-0/+32
Command::envs() adds a vector of key-value pairs to the child process environment all at once. Suggested in #38526.
2017-01-04Fix formattingabhijeetbhagat-1/+1
2017-01-04Fix formattingabhijeetbhagat-10/+10
2017-01-03Fix process module tests to run on Windowsabhijeetbhagat-18/+67
2016-12-20Rollup merge of #38006 - frewsxcv:libstd-debug, r=alexcrichtonAlex Crichton-0/+39
Implement `fmt::Debug` for all structures in libstd. Part of https://github.com/rust-lang/rust/issues/31869. Also turn on the `missing_debug_implementations` lint at the crate level.
2016-12-18Implement `fmt::Debug` for all structures in libstd.Corey Farwell-0/+39
Part of https://github.com/rust-lang/rust/issues/31869. Also turn on the `missing_debug_implementations` lint at the crate level.
2016-12-18Document platform-specific differences for `std::process::exit`.Corey Farwell-0/+17
Fixes https://github.com/rust-lang/rust/issues/35046.
2016-12-07Rollup merge of #38151 - GuillaumeGomez:exit-examples, r=frewsxcvGuillaume Gomez-0/+8
Add examples for exit function r? @frewsxcv
2016-12-05Auto merge of #38098 - luser:windows-commandext, r=alexcrichtonbors-0/+58
Add std::os::windows::process::CommandExt. Fixes #37827 This adds a CommandExt trait for Windows along with an implementation of it for std::process::Command with methods to set the process creation flags that are passed to CreateProcess.
2016-12-03Add examples for exit functionGuillaume Gomez-0/+8