Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seq: handle the error when stdout is full #5765

Merged
merged 1 commit into from Jan 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/uucore/src/lib/lib.rs
Expand Up @@ -105,9 +105,15 @@
($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();

Check warning on line 109 in src/uucore/src/lib/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/uucore/src/lib/lib.rs#L109

Added line #L109 was not covered by tests
// execute utility code
let code = $util::uumain(uucore::args_os());

Check warning on line 111 in src/uucore/src/lib/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/uucore/src/lib/lib.rs#L111

Added line #L111 was not covered by tests
// (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);

Check warning on line 114 in src/uucore/src/lib/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/uucore/src/lib/lib.rs#L114

Added line #L114 was not covered by tests
}

std::process::exit(code);
}
};
Expand Down