Drain the child processes stdout before waiting

For very large logs to stdout, this prevents deadlocks.
This commit is contained in:
Nick Fitzgerald 2017-07-17 12:54:51 -07:00
parent 159fe962b2
commit 02da6536e2

View File

@ -881,10 +881,6 @@ impl Builder {
}
let mut child = cmd.spawn()?;
if !child.wait()?.success() {
return Err(io::Error::new(io::ErrorKind::Other,
"clang exited with non-zero status"));
}
let mut preprocessed = child.stdout.take().unwrap();
let mut file = File::create(if is_cpp {
@ -893,7 +889,13 @@ impl Builder {
"__bindgen.i"
})?;
io::copy(&mut preprocessed, &mut file)?;
Ok(())
if child.wait()?.success() {
Ok(())
} else {
Err(io::Error::new(io::ErrorKind::Other,
"clang exited with non-zero status"))
}
}
}