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:
commit
3dc4191905
1 changed files with 12 additions and 2 deletions
14
mkmain.rs
14
mkmain.rs
|
@ -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);
|
||||
}
|
||||
";
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue