Skip to content

Commit

Permalink
use task::spawn_sched to read stdout and stderr at the same time
Browse files Browse the repository at this point in the history
Hopefully this addresses the root cause of the hangs when running make check on windows.
  • Loading branch information
tedhorst authored and brson committed Feb 11, 2012
1 parent a7a1152 commit 9fde2a5
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/compiletest/procsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,33 @@ fn run(lib_path: str, prog: str, args: [str],


writeclose(pipe_in.out, input);
let errput = readclose(pipe_err.in);
let output = readclose(pipe_out.in);
let p = comm::port();
let ch = comm::chan(p);
task::spawn_sched(1u) {||
let errput = readclose(pipe_err.in);
comm::send(ch, (2, errput));
};
task::spawn_sched(1u) {||
let output = readclose(pipe_out.in);
comm::send(ch, (1, output));
};
let status = run::waitpid(pid);
ret {status: status, out: output, err: errput};
let errs = "";
let outs = "";
let count = 2;
while count > 0 {
let stream = comm::recv(p);
alt stream {
(1, s) {
outs = s;
}
(2, s) {
errs = s;
}
};
count -= 1;
};
ret {status: status, out: outs, err: errs};
}

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

0 comments on commit 9fde2a5

Please sign in to comment.