Skip to content

Commit cc11fcb

Browse files
authored
Merge pull request #429 from sigmaSd/p
Exit gracefully when there is a broken pipe error
2 parents ee7643c + 70822fc commit cc11fcb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
99
### Fixed
1010

1111
* CI: Use Powershell Compress-Archive to create Windows binary zip #424 - @cyqsimon
12+
* Exit gracefully when there is a broken pipe error #429 - @sigmaSd
1213

1314
## [0.23.0] - 2024-08-17
1415

src/os/shared.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,14 @@ fn get_interface(interface_name: &str) -> Option<NetworkInterface> {
8383
fn create_write_to_stdout() -> Box<dyn FnMut(String) + Send> {
8484
let mut stdout = io::stdout();
8585
Box::new({
86-
move |output: String| {
87-
writeln!(stdout, "{}", output).unwrap();
86+
move |output: String| match writeln!(stdout, "{}", output) {
87+
Ok(_) => (),
88+
Err(e) if e.kind() == ErrorKind::BrokenPipe => {
89+
// A process that was listening to bandwhich stdout has exited
90+
// We can't do much here, lets just exit as well
91+
std::process::exit(0)
92+
}
93+
Err(e) => panic!("Failed to write to stdout: {e}"),
8894
}
8995
})
9096
}

0 commit comments

Comments
 (0)