Skip to content

Commit b0ba909

Browse files
authored
Fix run_output to prevent infinite blocking
If the child is blocked on writing to stderr and run_output blocked on reading stdout, then it'd be hung forever
1 parent 0597bc5 commit b0ba909

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/command_helpers.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -352,18 +352,13 @@ pub(crate) fn run_output(cmd: &mut Command, cargo_output: &CargoOutput) -> Resul
352352
// We specifically need the output to be captured, so override default
353353
let mut captured_cargo_output = cargo_output.clone();
354354
captured_cargo_output.output = OutputKind::Capture;
355-
let mut child = spawn(cmd, &captured_cargo_output)?;
355+
let Output {
356+
status,
357+
stdout,
358+
stderr,
359+
} = spawn(cmd, &captured_cargo_output)?.wait_with_output()?;
356360

357-
let mut stdout = vec![];
358-
child
359-
.stdout
360-
.take()
361-
.unwrap()
362-
.read_to_end(&mut stdout)
363-
.unwrap();
364-
365-
// Don't care about this output, use the normal settings
366-
StderrForwarder::new(child).forward_all();
361+
stderr.split(|&b| b == b'\n').for_each(write_warning);
367362

368363
let status = match child.wait() {
369364
Ok(s) => s,

0 commit comments

Comments
 (0)