mirror of
https://github.com/imsnif/bandwhich.git
synced 2026-02-09 01:59:18 +08:00
Merge pull request #429 from sigmaSd/p
Exit gracefully when there is a broken pipe error
This commit is contained in:
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
### Fixed
|
||||
|
||||
* CI: Use Powershell Compress-Archive to create Windows binary zip #424 - @cyqsimon
|
||||
* Exit gracefully when there is a broken pipe error #429 - @sigmaSd
|
||||
|
||||
## [0.23.0] - 2024-08-17
|
||||
|
||||
|
||||
@@ -83,8 +83,14 @@ fn get_interface(interface_name: &str) -> Option<NetworkInterface> {
|
||||
fn create_write_to_stdout() -> Box<dyn FnMut(String) + Send> {
|
||||
let mut stdout = io::stdout();
|
||||
Box::new({
|
||||
move |output: String| {
|
||||
writeln!(stdout, "{}", output).unwrap();
|
||||
move |output: String| match writeln!(stdout, "{}", output) {
|
||||
Ok(_) => (),
|
||||
Err(e) if e.kind() == ErrorKind::BrokenPipe => {
|
||||
// A process that was listening to bandwhich stdout has exited
|
||||
// We can't do much here, lets just exit as well
|
||||
std::process::exit(0)
|
||||
}
|
||||
Err(e) => panic!("Failed to write to stdout: {e}"),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user