Skip to content

Commit

Permalink
flush stdout/stderr to make sure it appears on the screen
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Feb 7, 2019
1 parent b1b9387 commit 68e8ff1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/fn_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 68e8ff1

Please sign in to comment.