let buf = this.read_scalar(buf)?.not_undef()?;
let count = this.read_scalar(count)?.to_machine_usize(this)?;
let result = if fd == 0 {
- throw_unsup_format!("reading from stdin is not implemented")
+ use std::io::{self, Read};
+
+ let mut buffer = String::new();
+ let res = io::stdin().read_to_string(&mut buffer);
+
+ match res {
+ Ok(bytes) => {
+ this.memory.write_bytes(buf, buffer.bytes())?;
+ i64::try_from(bytes).unwrap()
+ },
+ Err(_) => -1,
+ }
} else if fd == 1 || fd == 2 {
throw_unsup_format!("cannot read from stdout/stderr")
} else {