1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-02 14:07:46 +00:00

Merge pull request #629 from jbcrail/flush-stdout-from-main

Ensure any pending stdout writes are flushed.
This commit is contained in:
Heather 2015-05-31 08:47:10 +03:00
commit 3dc4191905

View file

@ -5,11 +5,21 @@ use std::fs::File;
static TEMPLATE: &'static str = "\
extern crate @UTIL_CRATE@ as uu@UTIL_CRATE@;
use std::env;
use std::io::Write;
use uu@UTIL_CRATE@::uumain;
fn main() {
std::process::exit(uumain(env::args().collect()));
let code = uumain(std::env::args().collect());
// Since stdout is line-buffered by default, we need to ensure any pending
// writes are flushed before exiting. Ideally, this should be enforced by
// each utility.
//
// See: https://github.com/rust-lang/rust/issues/23818
//
std::io::stdout().flush().unwrap();
std::process::exit(code);
}
";