Ignore 'Broken Pipe' if child process does not read all of stdin (#1244)

* Ignore 'Broken Pipe' if child process does not read all of stdin

* follow clippy suggestion
This commit is contained in:
Arpan Kapoor 2023-05-03 19:15:27 +05:30 committed by GitHub
parent abd8efabd3
commit c8c5d89f33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -135,8 +135,15 @@ impl CommandConfigurator for StdCommandConfigurator {
self.command.stdin(Stdio::piped()).spawn()?; self.command.stdin(Stdio::piped()).spawn()?;
let mut handle = self.command.spawn()?; let mut handle = self.command.spawn()?;
let mut stdin = handle.stdin.take().unwrap(); let mut stdin = handle.stdin.take().unwrap();
stdin.write_all(input.target_bytes().as_slice())?; if let Err(err) = stdin.write_all(input.target_bytes().as_slice()) {
stdin.flush()?; if err.kind() != std::io::ErrorKind::BrokenPipe {
return Err(err.into());
}
} else if let Err(err) = stdin.flush() {
if err.kind() != std::io::ErrorKind::BrokenPipe {
return Err(err.into());
}
}
drop(stdin); drop(stdin);
Ok(handle) Ok(handle)
} }