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

handle the error when stdout is full

Avoid panic when using
seq 1 >/dev/full

Should move tests/csplit/csplit-io-err.sh from ERROR to SKIP
This commit is contained in:
Sylvestre Ledru 2024-01-01 16:57:47 +01:00
parent 5fc01f718a
commit f53f9b6496

View file

@ -105,9 +105,15 @@ macro_rules! bin {
($util:ident) => {
pub fn main() {
use std::io::Write;
uucore::panic::mute_sigpipe_panic(); // suppress extraneous error output for SIGPIPE failures/panics
let code = $util::uumain(uucore::args_os()); // execute utility code
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>
// suppress extraneous error output for SIGPIPE failures/panics
uucore::panic::mute_sigpipe_panic();
// 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);
}
};