mikros: Do not close stdio after every use
This commit is contained in:
parent
7bd76e861a
commit
5ccb37a3f7
@ -26,8 +26,9 @@ impl io::Read for Stdin {
|
|||||||
return Ok(0);
|
return Ok(0);
|
||||||
};
|
};
|
||||||
let file = File { fs_pid: fd.0, fd: fd.1, pos: AtomicUsize::new(0) };
|
let file = File { fs_pid: fd.0, fd: fd.1, pos: AtomicUsize::new(0) };
|
||||||
let num_bytes = file.read(buf)?;
|
let res = file.read(buf);
|
||||||
Ok(num_bytes)
|
crate::mem::drop(file); // do not close the temporary file struct
|
||||||
|
res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +50,9 @@ impl io::Write for Stdout {
|
|||||||
return Ok(0);
|
return Ok(0);
|
||||||
};
|
};
|
||||||
let file = File { fs_pid: fd.0, fd: fd.1, pos: AtomicUsize::new(0) };
|
let file = File { fs_pid: fd.0, fd: fd.1, pos: AtomicUsize::new(0) };
|
||||||
file.write(buf)
|
let res = file.write(buf);
|
||||||
|
crate::mem::drop(file); // do not close the temporary file struct
|
||||||
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&mut self) -> io::Result<()> {
|
fn flush(&mut self) -> io::Result<()> {
|
||||||
@ -75,7 +78,9 @@ impl io::Write for Stderr {
|
|||||||
return Ok(0);
|
return Ok(0);
|
||||||
};
|
};
|
||||||
let file = File { fs_pid: fd.0, fd: fd.1, pos: AtomicUsize::new(0) };
|
let file = File { fs_pid: fd.0, fd: fd.1, pos: AtomicUsize::new(0) };
|
||||||
file.write(buf)
|
let res = file.write(buf);
|
||||||
|
crate::mem::drop(file); // do not close the temporary file struct
|
||||||
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&mut self) -> io::Result<()> {
|
fn flush(&mut self) -> io::Result<()> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user