Skip to content

Commit 02da653

Browse files
committed
Drain the child processes stdout before waiting
For very large logs to stdout, this prevents deadlocks.
1 parent 159fe96 commit 02da653

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -881,10 +881,6 @@ impl Builder {
881881
}
882882

883883
let mut child = cmd.spawn()?;
884-
if !child.wait()?.success() {
885-
return Err(io::Error::new(io::ErrorKind::Other,
886-
"clang exited with non-zero status"));
887-
}
888884

889885
let mut preprocessed = child.stdout.take().unwrap();
890886
let mut file = File::create(if is_cpp {
@@ -893,7 +889,13 @@ impl Builder {
893889
"__bindgen.i"
894890
})?;
895891
io::copy(&mut preprocessed, &mut file)?;
896-
Ok(())
892+
893+
if child.wait()?.success() {
894+
Ok(())
895+
} else {
896+
Err(io::Error::new(io::ErrorKind::Other,
897+
"clang exited with non-zero status"))
898+
}
897899
}
898900
}
899901

0 commit comments

Comments
 (0)