Skip to content

Instantly share code, notes, and snippets.

@raindev
Created September 5, 2015 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raindev/d31939254581dc4abf90 to your computer and use it in GitHub Desktop.
Save raindev/d31939254581dc4abf90 to your computer and use it in GitHub Desktop.
A simple Rust program to demonstrate loss of cached stdout
use std::fs;
use std::env;
use std::process;
fn main() {
match env::args_os().nth(1) {
None => {
print!("nope");
print!("okay");
// will cause losss of stdout buffered above
process::exit(1)
},
Some(dir_name) => match fs::read_dir(dir_name) {
Ok(d) => println!("{}", d.count()),
Err(e) => println!("{}", e),
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment