Skip to content

Commit b921d9e

Browse files
committed
---
yaml --- r: 95632 b: refs/heads/dist-snap c: 262b958 h: refs/heads/master v: v3
1 parent 1d7f09d commit b921d9e

File tree

4 files changed

+41
-20
lines changed

4 files changed

+41
-20
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 6bb1df92511e7ecafe0554b01410f4e68d7bc66f
9+
refs/heads/dist-snap: 262b958a4bedf419335069c95f054a22da48a88a
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libstd/rt/io/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub struct ProcessConfig<'self> {
5757
/// 0 - stdin
5858
/// 1 - stdout
5959
/// 2 - stderr
60-
io: ~[StdioContainer]
60+
io: &'self [StdioContainer]
6161
}
6262

6363
/// Describes what to do with a standard io stream for a child process.

branches/dist-snap/src/libstd/rt/uv/process.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use prelude::*;
1212
use cell::Cell;
1313
use libc;
1414
use ptr;
15-
use util;
1615
use vec;
1716

1817
use rt::io::process::*;
@@ -42,7 +41,7 @@ impl Process {
4241
///
4342
/// Returns either the corresponding process object or an error which
4443
/// occurred.
45-
pub fn spawn(&mut self, loop_: &uv::Loop, mut config: ProcessConfig,
44+
pub fn spawn(&mut self, loop_: &uv::Loop, config: ProcessConfig,
4645
exit_cb: uv::ExitCallback)
4746
-> Result<~[Option<~UvPipeStream>], uv::UvError>
4847
{
@@ -62,12 +61,12 @@ impl Process {
6261
err);
6362
}
6463

65-
let io = util::replace(&mut config.io, ~[]);
64+
let io = config.io;
6665
let mut stdio = vec::with_capacity::<uvll::uv_stdio_container_t>(io.len());
6766
let mut ret_io = vec::with_capacity(io.len());
6867
unsafe {
6968
vec::raw::set_len(&mut stdio, io.len());
70-
for (slot, other) in stdio.iter().zip(io.move_iter()) {
69+
for (slot, other) in stdio.iter().zip(io.iter()) {
7170
let io = set_stdio(slot as *uvll::uv_stdio_container_t, other,
7271
loop_);
7372
ret_io.push(io);
@@ -126,9 +125,9 @@ impl Process {
126125
}
127126

128127
unsafe fn set_stdio(dst: *uvll::uv_stdio_container_t,
129-
io: StdioContainer,
128+
io: &StdioContainer,
130129
loop_: &uv::Loop) -> Option<~UvPipeStream> {
131-
match io {
130+
match *io {
132131
Ignored => {
133132
uvll::set_stdio_container_flags(dst, uvll::STDIO_IGNORE);
134133
None

branches/dist-snap/src/libstd/run.rs

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use comm::{stream, SharedChan};
1717
use libc::{pid_t, c_int};
1818
use libc;
1919
use prelude::*;
20-
use rt::io::native::process;
20+
use rt::io::process;
2121
use rt::io;
2222
use rt::io::extensions::ReaderUtil;
2323
use task;
@@ -122,8 +122,24 @@ impl Process {
122122
*/
123123
pub fn new(prog: &str, args: &[~str], options: ProcessOptions) -> Process {
124124
let ProcessOptions { env, dir, in_fd, out_fd, err_fd } = options;
125-
let inner = process::Process::new(prog, args, env, dir,
126-
in_fd, out_fd, err_fd);
125+
let env = env.as_ref().map(|a| a.as_slice());
126+
let cwd = dir.as_ref().map(|a| a.as_str().unwrap());
127+
fn rtify(fd: Option<c_int>, input: bool) -> process::StdioContainer {
128+
match fd {
129+
Some(fd) => process::InheritFd(fd),
130+
None => process::CreatePipe(input, !input),
131+
}
132+
}
133+
let rtio = [rtify(in_fd, true), rtify(out_fd, false),
134+
rtify(err_fd, false)];
135+
let rtconfig = process::ProcessConfig {
136+
program: prog,
137+
args: args,
138+
env: env,
139+
cwd: cwd,
140+
io: rtio,
141+
};
142+
let inner = process::Process::new(rtconfig).unwrap();
127143
Process { inner: inner }
128144
}
129145

@@ -136,34 +152,40 @@ impl Process {
136152
* Fails if there is no stdin available (it's already been removed by
137153
* take_input)
138154
*/
139-
pub fn input<'a>(&'a mut self) -> &'a mut io::Writer { self.inner.input() }
155+
pub fn input<'a>(&'a mut self) -> &'a mut io::Writer {
156+
self.inner.io[0].get_mut_ref() as &mut io::Writer
157+
}
140158

141159
/**
142160
* Returns an io::Reader that can be used to read from this Process's stdout.
143161
*
144162
* Fails if there is no stdout available (it's already been removed by
145163
* take_output)
146164
*/
147-
pub fn output<'a>(&'a mut self) -> &'a mut io::Reader { self.inner.output() }
165+
pub fn output<'a>(&'a mut self) -> &'a mut io::Reader {
166+
self.inner.io[1].get_mut_ref() as &mut io::Reader
167+
}
148168

149169
/**
150170
* Returns an io::Reader that can be used to read from this Process's stderr.
151171
*
152172
* Fails if there is no stderr available (it's already been removed by
153173
* take_error)
154174
*/
155-
pub fn error<'a>(&'a mut self) -> &'a mut io::Reader { self.inner.error() }
175+
pub fn error<'a>(&'a mut self) -> &'a mut io::Reader {
176+
self.inner.io[2].get_mut_ref() as &mut io::Reader
177+
}
156178

157179
/**
158180
* Closes the handle to the child process's stdin.
159181
*/
160182
pub fn close_input(&mut self) {
161-
self.inner.take_input();
183+
self.inner.io[0].take();
162184
}
163185

164186
fn close_outputs(&mut self) {
165-
self.inner.take_output();
166-
self.inner.take_error();
187+
self.inner.io[1].take();
188+
self.inner.io[2].take();
167189
}
168190

169191
/**
@@ -186,9 +208,9 @@ impl Process {
186208
* were redirected to existing file descriptors.
187209
*/
188210
pub fn finish_with_output(&mut self) -> ProcessOutput {
189-
self.inner.take_input(); // close stdin
190-
let output = Cell::new(self.inner.take_output());
191-
let error = Cell::new(self.inner.take_error());
211+
self.close_input();
212+
let output = Cell::new(self.inner.io[1].take());
213+
let error = Cell::new(self.inner.io[2].take());
192214

193215
// Spawn two entire schedulers to read both stdout and sterr
194216
// in parallel so we don't deadlock while blocking on one

0 commit comments

Comments
 (0)