-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement CommandExt::{exec, before_exec} #31409
Commits on Feb 10, 2016
-
std: Refactor process spawning on Unix
* 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.
Configuration menu - View commit details
-
Copy full SHA for 6c41984 - Browse repository at this point
Copy the full SHA 6c41984View commit details -
std: Implement CommandExt::before_exec
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 rust-lang#31398
Configuration menu - View commit details
-
Copy full SHA for b1898db - Browse repository at this point
Copy the full SHA b1898dbView commit details -
std: Push Child's exit status to sys::process
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 0e190b9 to solve rust-lang#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.
Configuration menu - View commit details
-
Copy full SHA for 627515a - Browse repository at this point
Copy the full SHA 627515aView commit details -
std: Rename Stdio::None to Stdio::Null
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".
Configuration menu - View commit details
-
Copy full SHA for b8bd8f3 - Browse repository at this point
Copy the full SHA b8bd8f3View commit details -
std: Lift out Windows' CreateProcess lock a bit
The function `CreateProcess` is not itself unsafe to call from many threads, the article in question is pointing out that handles can be inherited by unintended child processes. This is basically the same race as the standard Unix open-then-set-cloexec race. Since the intention of the lock is to protect children from inheriting unintended handles, the lock is now lifted out to before the creation of the child I/O handles (which will all be inheritable). This will ensure that we only have one process in Rust at least creating inheritable handles at a time, preventing unintended inheritance to children.
Configuration menu - View commit details
-
Copy full SHA for 18f9a79 - Browse repository at this point
Copy the full SHA 18f9a79View commit details -
std: Push process stdio setup in std::sys
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.
Configuration menu - View commit details
-
Copy full SHA for d15db1d - Browse repository at this point
Copy the full SHA d15db1dView commit details -
std: Implement CommandExt::exec
This commit implements the `exec` function proposed in [RFC 1359][rfc] which is a function on the `CommandExt` trait to execute all parts of a `Command::spawn` without the `fork` on Unix. More details on the function itself can be found in the comments in the commit. [rfc]: rust-lang/rfcs#1359 cc rust-lang#31398
Configuration menu - View commit details
-
Copy full SHA for b37477c - Browse repository at this point
Copy the full SHA b37477cView commit details -
std: Use macros from libc instead of locally
Helps cut down on #[cfg]!
Configuration menu - View commit details
-
Copy full SHA for efb23db - Browse repository at this point
Copy the full SHA efb23dbView commit details -
std: Move constant back to where it needs to be
Lost track of this during the std::process refactorings
Configuration menu - View commit details
-
Copy full SHA for d9c6a51 - Browse repository at this point
Copy the full SHA d9c6a51View commit details