about summary refs log tree commit diff
path: root/src/libstd/process.rs
AgeCommit message (Collapse)AuthorLines
2016-05-09Auto merge of #33224 - alexcrichton:create-exit-status, r=aturonbors-0/+6
std: Allow creating ExitStatus from raw values Sometimes a process may be waited on externally from the standard library, in which case it can be useful to create a raw `ExitStatus` structure to return. This commit extends the existing Unix `ExitStatusExt` extension trait and adds a new Windows-specific `ExitStatusExt` extension trait to do this. The methods are currently called `ExitStatus::from_raw`. cc #32713
2016-05-01Add process types documentationGuillaume Gomez-4/+196
2016-04-26std: Allow creating ExitStatus from raw valuesAlex Crichton-0/+6
Sometimes a process may be waited on externally from the standard library, in which case it can be useful to create a raw `ExitStatus` structure to return. This commit extends the existing Unix `ExitStatusExt` extension trait and adds a new Windows-specific `ExitStatusExt` extension trait to do this. The methods are currently called `ExitStatus::from_raw`. cc #32713
2016-04-15Auto merge of #32338 - lukaspustina:doc-std-process, r=alexcrichtonbors-11/+37
Extends rustdoc on how to caputure output - The documentation is quite about how to caputure a process' output when using ` std::process::Child::wait_with_output()`. - This PR adds an example for this particular use case.
2016-03-26Rollup merge of #32257 - alexcrichton:fix-status-stdin, r=aturonManish Goregaokar-1/+1
std: Fix inheriting stdin on status() This regression was accidentally introduced in #31618, and it's just flipping a boolean! Closes #32254
2016-03-22try! -> ?Jorge Aparicio-1/+1
Automated conversion using the untry tool [1] and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [1]: https://github.com/japaric/untry
2016-03-22Fixes test which are now run due to should_panicLukas Pustina-1/+5
Since I changed no_run to should_panic on some tests, the were run but two lacked an actual assertion. Further, I missed to check the return type on another test.
2016-03-21Adjusts all rust doc test to use `expect` and `should_panic`Lukas Pustina-14/+13
- All Rust Doc tests execute the same command `/bin/cat file.txt` which `should_panic` on all platforms consistently, because either `/bin/cat` or `file.txt` do not exist.
2016-03-19Fixes 2. stdout to stderr in rustdocLukas Pustina-1/+1
2016-03-19Revert "Tags new test as `no_run` and uses expect()"Lukas Pustina-3/+4
- After discussing with @alexcrichton, the initial commit has been fine. This reverts commit 3b5cfa3ecf4e44b251ce121ab5dcf53c35de8eea.
2016-03-18Tags new test as `no_run` and uses expect()Lukas Pustina-4/+3
2016-03-18Extends rustdoc on how to caputure outputLukas Pustina-0/+23
2016-03-14std: Fix inheriting stdin on status()Alex Crichton-1/+1
This regression was accidentally introduced in #31618, and it's just flipping a boolean! Closes #32254
2016-03-09std: Don't spawn threads in `wait_with_output`Alex Crichton-16/+20
Semantically there's actually no reason for us to spawn threads as part of the call to `wait_with_output`, and that's generally an incredibly heavyweight operation for just reading a few bytes (especially when stderr probably rarely has bytes!). An equivalent operation in terms of what's implemented today would be to just drain both pipes of all contents and then call `wait` on the child process itself. On Unix we can implement this through some convenient use of the `select` function, whereas on Windows we can make use of overlapped I/O. Note that on Windows this requires us to use named pipes instead of anonymous pipes, but they're semantically the same under the hood.
2016-03-08std: Don't always create stdin for childrenAlex Crichton-3/+4
For example if `Command::output` or `Command::status` is used then stdin is just immediately closed. Add an option for this so as an optimization we can avoid creating pipes entirely. This should help reduce the number of active file descriptors when spawning processes on Unix and the number of active handles on Windows.
2016-03-08std: Funnel read_to_end through to one locationAlex Crichton-0/+6
This pushes the implementation detail of proxying `read_to_end` through to `read_to_end_uninitialized` all the way down to the `FileDesc` and `Handle` implementations on Unix/Windows. This way intermediate layers will also be able to take advantage of this optimized implementation. This commit also adds the optimized implementation for `ChildStdout` and `ChildStderr`.
2016-02-10std: Push process stdio setup in std::sysAlex Crichton-85/+44
Most of this is platform-specific anyway, and we generally have to jump through fewer hoops to do the equivalent operation on Windows. One benefit for Windows today is that this new structure avoids an extra `DuplicateHandle` when creating pipes. For Unix, however, the behavior should be the same. Note that this is just a pure refactoring, no functionality was added or removed.
2016-02-10std: Rename Stdio::None to Stdio::NullAlex Crichton-3/+3
This better reflects what it's actually doing as we don't actually have an option for "leave this I/O slot as an empty hole".
2016-02-10std: Push Child's exit status to sys::processAlex Crichton-44/+5
On Unix we have to be careful to not call `waitpid` twice, but we don't have to be careful on Windows due to the way process handles work there. As a result the cached `Option<ExitStatus>` is only necessary on Unix, and it's also just an implementation detail of the Unix module. At the same time. also update some code in `kill` on Unix to avoid a wonky waitpid with WNOHANG. This was added in 0e190b9a to solve #13124, but the `signal(0)` method is not supported any more so there's no need to for this workaround. I believe that this is no longer necessary as it's not really doing anything.
2016-02-10std: Implement CommandExt::before_execAlex Crichton-2/+2
This is a Unix-specific function which adds the ability to register a closure to run pre-exec to configure the child process as required (note that these closures are run post-fork). cc #31398
2016-02-10std: Refactor process spawning on UnixAlex Crichton-1/+3
* Build up the argp/envp pointers while the `Command` is being constructed rather than only when `spawn` is called. This will allow better sharing of code between fork/exec paths. * Rename `child_after_fork` to `exec` and have it only perform the exec half of the spawning. This also means the return type has changed to `io::Error` rather than `!` to represent errors that happen.
2016-02-03Auto merge of #31056 - kamalmarhubi:std-process-nul-chars, r=alexcrichtonbors-5/+51
This reports an error at the point of calling `Command::spawn()` or one of its equivalents. Fixes #30858 Fixes #30862
2016-02-03std: Properly handle interior NULs in std::processKamal Marhubi-5/+51
This reports an error at the point of calling `Command::spawn()` or one of its equivalents. Fixes https://github.com/rust-lang/rust/issues/30858 Fixes https://github.com/rust-lang/rust/issues/30862
2016-01-31Minor corrections in docs for `std::process::Child`Dirk Gadsden-4/+6
2016-01-31Safety docs about `std::process::Child` going out of scopeDirk Gadsden-0/+8
There is no `Drop` implemented for `Child`, so if it goes out of scope in Rust-land and gets deallocated, the child process will continue to exist and execute. If users want a guarantee that the process has finished running and exited they must manually use `kill`, `wait`, or `wait_with_output`. Fixes #31289.
2016-01-26Fix warnings during testsAlex Crichton-37/+25
The deny(warnings) attribute is now enabled for tests so we need to weed out these warnings as well.
2015-12-17Add a debug implementation to process::OutputEd Clarke-0/+27
2015-12-01Fix typo in src/libstd/process.rsAdam Badawy-1/+1
2015-11-23skip check for DYLD envars in child procJosh Austin-0/+1
2015-11-22test_inherit_env: Don't look for hidden environment variables on WindowsTobias Bucher-2/+4
Fixes #29972.
2015-11-17std: Use join() in Process::wait_with_outputAlex Crichton-20/+14
Previously this function used channels but this isn't necessary any more now that threads have return values. This also has the added bonus of appropriately waiting for the thread to exit to ensure that the function doesn't still have running threads once it returns.
2015-10-20Rollup merge of #29158 - arcnmx:process-test, r=alexcrichtonSteve Klabnik-1/+1
This test was mysteriously messed with as part of #28500 r? @alexcrichton
2015-10-19Correct spelling in docsAndrew Paseltiner-2/+2
2015-10-19Add missing #[test] attribute to testarcnmx-1/+1
2015-10-13Correct spelling in docsAndrew Paseltiner-1/+1
2015-09-29Tweak Travis to use GCEAlex Crichton-5/+8
Travis CI has new infrastructure using the Google Compute Engine which has both faster CPUs and more memory, and we've been encouraged to switch as it should help our build times! The only downside currently, however, is that IPv6 is disabled, causing a number of standard library tests to fail. Consequently this commit tweaks our travis config in a few ways: * ccache is disabled as it's not working on GCE just yet * Docker is used to run tests inside which reportedly will get IPv6 working * A system LLVM installation is used instead of building LLVM itself. This is primarily done to reduce build times, but we want automation for this sort of behavior anyway and we can extend this in the future with building from source as well if needed. * gcc-specific logic is removed as the docker image for Ubuntu gives us a recent-enough gcc by default.
2015-09-11std: Internalize almost all of `std::rt`Alex Crichton-1/+1
This commit does some refactoring to make almost all of the `std::rt` private. Specifically, the following items are no longer part of its API: * DEFAULT_ERROR_CODE * backtrace * unwind * args * at_exit * cleanup * heap (this is just alloc::heap) * min_stack * util The module is now tagged as `#[doc(hidden)]` as the only purpose it's serve is an entry point for the `panic!` macro via the `begin_unwind` and `begin_unwind_fmt` reexports.
2015-09-02std: Run at_exit cleanup on process::exitAlex Crichton-0/+1
This adds a call to `rt::cleanup` on `process::exit` to make sure we clean up after ourselves on the way out from Rust. Closes #28065
2015-08-04syntax: Don't assume `std` exists for testsAlex Crichton-1/+1
This commit removes the injection of `std::env::args()` from `--test` expanded code, relying on the test runner itself to call this funciton. This is more hygienic because we can't assume that `std` exists at the top layer all the time, and it meaks the injected test module entirely self contained.
2015-07-31Auto merge of #27370 - alexcrichton:stabilize-easy, r=brsonbors-1/+1
The following APIs were all marked with a `#[stable]` tag: * process::Child::id * error::Error::is * error::Error::downcast * error::Error::downcast_ref * error::Error::downcast_mut * io::Error::get_ref * io::Error::get_mut * io::Error::into_inner * hash::Hash::hash_slice * hash::Hasher::write_{i,u}{8,16,32,64,size}
2015-07-29std: Remove the curious inner moduleAlex Crichton-1/+1
This isn't actually necessary any more with the advent of `$crate` and changes in the compiler to expand macros to `::core::$foo` in the context of a `#![no_std]` crate. The libcore inner module was also trimmed down a bit to the bare bones.
2015-07-28std: Stabilize a number of small APIsAlex Crichton-1/+1
The following APIs were all marked with a `#[stable]` tag: * process::Child::id * error::Error::is * error::Error::downcast * error::Error::downcast_ref * error::Error::downcast_mut * io::Error::get_ref * io::Error::get_mut * io::Error::into_inner * hash::Hash::hash_slice * hash::Hasher::write_{i,u}{8,16,32,64,size}
2015-07-27std: Remove msvc/valgrind headersAlex Crichton-11/+2
These aren't really used for anything any more, so there doesn't seem to be much reason to leave them around in the `rt` directory. There was some limiting of threads spawned or tests when run under valgrind, but very little is run under valgrind nowadays so there's also no real use keeping these around.
2015-07-20std: Add IntoRaw{Fd,Handle,Socket} traitsAlex Crichton-1/+17
This commit is an implementation of [RFC 1174][rfc] which adds three new traits to the standard library: * `IntoRawFd` - implemented on Unix for all I/O types (files, sockets, etc) * `IntoRawHandle` - implemented on Windows for files, processes, etc * `IntoRawSocket` - implemented on Windows for networking types [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1174-into-raw-fd-socket-handle-traits.md Closes #27062
2015-06-22std::process: Remove helper function pwd_cmd from test moduleGeoffrey Thomas-18/+0
The test that used it was removed in 700e627cf727873a472b1876238aac10b932258b.
2015-06-09std: Tweak process raising/lowering implementationsAlex Crichton-13/+28
* Slate these features to be stable in 1.2 instead of 1.1 (not being backported) * Have the `FromRawFd` implementations follow the contract of the `FromRawFd` trait by taking ownership of the primitive specified. * Refactor the implementations slightly to remove the `unreachable!` blocks as well as separating the stdio representation of `std::process` from `std::sys::process`.
2015-06-05Another small grammar fix for process.rsMartin Pool-1/+1
2015-06-05Doc fix for process.rsMartin Pool-1/+1
File handles are inherited from, not by, the parent process
2015-05-29Auto merge of #25494 - alexcrichton:stdio-from-raw, r=aturonbors-41/+58
This commit implements a number of standard traits for the standard library's process I/O handles. The `FromRaw{Fd,Handle}` traits are now implemented for the `Stdio` type and the `AsRaw{Fd,Handle}` traits are now implemented for the `Child{Stdout,Stdin,Stderr}` types. The stability markers for these implementations mention that they are stable for 1.1 as I will nominate this commit for cherry-picking to beta.
2015-05-16std: Implement lowering and raising for process IOAlex Crichton-41/+58
This commit implements a number of standard traits for the standard library's process I/O handles. The `FromRaw{Fd,Handle}` traits are now implemented for the `Stdio` type and the `AsRaw{Fd,Handle}` traits are now implemented for the `Child{Stdout,Stdin,Stderr}` types. Additionally this implements the `AsRawHandle` trait for `Child` on Windows. The stability markers for these implementations mention that they are stable for 1.1 as I will nominate this commit for cherry-picking to beta.