Skip to content

Commit

Permalink
Ignore broken pipe error when sending test input
Browse files Browse the repository at this point in the history
This fixes a "Broken pipe (os error 32)" error during tests, which
occurs when the solution exits or is killed by timeout before the entire
input is sent.
  • Loading branch information
j-tai committed Mar 1, 2020
1 parent 3e43809 commit 0acd74d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,13 @@ impl Program<'_> {
let mut child = cmd.spawn()?;
let mut stdin = child.stdin.take().unwrap();
// This thread copies the input data to the process's stdin.
let in_thread = thread::spawn(move || stdin.write_all(&input));
let in_thread = thread::spawn(move || {
match stdin.write_all(&input) {
Ok(()) => Ok(()),
Err(ref e) if e.kind() == ErrorKind::BrokenPipe => Ok(()),
Err(e) => Err(e),
}
});
let mut stdout = child.stdout.take().unwrap();
let (send, recv) = mpsc::channel();
// This thread reads the output from the child process.
Expand Down

0 comments on commit 0acd74d

Please sign in to comment.