Skip to content

Commit 442968b

Browse files
committed
also support writing to stderr
1 parent 4bfecec commit 442968b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/terminator/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,11 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
587587
let buf = args[1].read_ptr(&self.memory)?;
588588
let n = self.value_to_primval(args[2], usize)?.to_u64()?;
589589
trace!("Called write({:?}, {:?}, {:?})", fd, buf, n);
590-
let result = if fd == 1 { // stdout
590+
let result = if fd == 1 || fd == 2 { // stdout/stderr
591591
use std::io::{self, Write};
592592

593593
let buf_cont = self.memory.read_bytes(buf, n)?;
594-
let res = io::stdout().write(buf_cont);
594+
let res = if fd == 1 { io::stdout().write(buf_cont) } else { io::stderr().write(buf_cont) };
595595
match res { Ok(n) => n as isize, Err(_) => -1 }
596596
} else {
597597
info!("Ignored output to FD {}", fd);

0 commit comments

Comments
 (0)