Merge pull request #619 from RalfJung/stderr-flush

flush stdout/stderr to make sure it appears on the screen
This commit is contained in:
Oliver Scherer 2019-02-08 09:47:39 +01:00 committed by GitHub
commit 77d12bb465
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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,