Skip to content

Commit

Permalink
Drain the child processes stdout before waiting
Browse files Browse the repository at this point in the history
For very large logs to stdout, this prevents deadlocks.
  • Loading branch information
fitzgen committed Jul 18, 2017
1 parent 159fe96 commit 02da653
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"))
}
}
}

Expand Down

0 comments on commit 02da653

Please sign in to comment.