]> git.lizzy.rs Git - rust.git/commitdiff
flush stdout/stderr to make sure it appears on the screen
authorRalf Jung <post@ralfj.de>
Thu, 7 Feb 2019 17:04:54 +0000 (18:04 +0100)
committerRalf Jung <post@ralfj.de>
Thu, 7 Feb 2019 17:04:58 +0000 (18:04 +0100)
src/fn_call.rs

index abb239ad7d62792d04a52a0ed066537eb45d9d57..56cb38645090895cc281b67b4a18c3c4438eca0e 100644 (file)
@@ -390,10 +390,15 @@ fn emulate_foreign_item(
                     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,