Skip to content

Commit 6c41984

Browse files
committed
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.
1 parent 096dbf8 commit 6c41984

File tree

4 files changed

+166
-168
lines changed

4 files changed

+166
-168
lines changed

src/libstd/process.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ impl Command {
209209
/// Add multiple arguments to pass to the program.
210210
#[stable(feature = "process", since = "1.0.0")]
211211
pub fn args<S: AsRef<OsStr>>(&mut self, args: &[S]) -> &mut Command {
212-
self.inner.args(args.iter().map(AsRef::as_ref));
212+
for arg in args {
213+
self.arg(arg.as_ref());
214+
}
213215
self
214216
}
215217

src/libstd/sys/unix/ext/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414

15-
use os::unix::raw::{uid_t, gid_t};
1615
use os::unix::io::{FromRawFd, RawFd, AsRawFd, IntoRawFd};
16+
use os::unix::raw::{uid_t, gid_t};
1717
use process;
1818
use sys;
1919
use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};

0 commit comments

Comments
 (0)