Skip to content

Commit 9fde2a5

Browse files
tedhorstbrson
authored andcommitted
use task::spawn_sched to read stdout and stderr at the same time
Hopefully this addresses the root cause of the hangs when running make check on windows.
1 parent a7a1152 commit 9fde2a5

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/compiletest/procsrv.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,33 @@ fn run(lib_path: str, prog: str, args: [str],
5252

5353

5454
writeclose(pipe_in.out, input);
55-
let errput = readclose(pipe_err.in);
56-
let output = readclose(pipe_out.in);
55+
let p = comm::port();
56+
let ch = comm::chan(p);
57+
task::spawn_sched(1u) {||
58+
let errput = readclose(pipe_err.in);
59+
comm::send(ch, (2, errput));
60+
};
61+
task::spawn_sched(1u) {||
62+
let output = readclose(pipe_out.in);
63+
comm::send(ch, (1, output));
64+
};
5765
let status = run::waitpid(pid);
58-
ret {status: status, out: output, err: errput};
66+
let errs = "";
67+
let outs = "";
68+
let count = 2;
69+
while count > 0 {
70+
let stream = comm::recv(p);
71+
alt stream {
72+
(1, s) {
73+
outs = s;
74+
}
75+
(2, s) {
76+
errs = s;
77+
}
78+
};
79+
count -= 1;
80+
};
81+
ret {status: status, out: outs, err: errs};
5982
}
6083

6184
fn writeclose(fd: fd_t, s: option<str>) {

0 commit comments

Comments
 (0)