flush stdout/stderr to make sure it appears on the screen

This commit is contained in:
Ralf Jung 2019-02-07 18:04:54 +01:00
parent b1b9387c33
commit 68e8ff1a09

View file

@ -390,10 +390,15 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
use std::io::{self, Write};
let buf_cont = this.memory().read_bytes(buf, Size::from_bytes(n))?;
// We need to flush to make sure this actually appears on the screen
let res = if fd == 1 {
io::stdout().write(buf_cont)
let res = io::stdout().write(buf_cont);
io::stdout().flush().unwrap();
res
} else {
io::stderr().write(buf_cont)
let res = io::stderr().write(buf_cont);
io::stderr().flush().unwrap();
res
};
match res {
Ok(n) => n as i64,