1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

Merge pull request #5765 from sylvestre/handle-full

handle the error when stdout is full
This commit is contained in:
Daniel Hofstetter 2024-01-02 08:31:19 +01:00 committed by GitHub
commit 9f257adf59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -105,9 +105,15 @@ macro_rules! bin {
($util:ident) => { ($util:ident) => {
pub fn main() { pub fn main() {
use std::io::Write; use std::io::Write;
uucore::panic::mute_sigpipe_panic(); // suppress extraneous error output for SIGPIPE failures/panics // suppress extraneous error output for SIGPIPE failures/panics
let code = $util::uumain(uucore::args_os()); // execute utility code uucore::panic::mute_sigpipe_panic();
std::io::stdout().flush().expect("could not flush stdout"); // (defensively) flush stdout for utility prior to exit; see <https://github.com/rust-lang/rust/issues/23818> // execute utility code
let code = $util::uumain(uucore::args_os());
// (defensively) flush stdout for utility prior to exit; see <https://github.com/rust-lang/rust/issues/23818>
if let Err(e) = std::io::stdout().flush() {
eprintln!("Error flushing stdout: {}", e);
}
std::process::exit(code); std::process::exit(code);
} }
}; };