2 use crate::sys::fd::FileDesc;
9 pub fn new() -> Stdin {
14 impl io::Read for Stdin {
15 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
16 let fd = FileDesc::new(libc::STDIN_FILENO);
17 let ret = fd.read(buf);
18 fd.into_raw(); // do not close this FD
24 pub fn new() -> Stdout {
29 impl io::Write for Stdout {
30 fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
31 let fd = FileDesc::new(libc::STDOUT_FILENO);
32 let ret = fd.write(buf);
33 fd.into_raw(); // do not close this FD
37 fn flush(&mut self) -> io::Result<()> {
43 pub fn new() -> Stderr {
48 impl io::Write for Stderr {
49 fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
50 let fd = FileDesc::new(libc::STDERR_FILENO);
51 let ret = fd.write(buf);
52 fd.into_raw(); // do not close this FD
56 fn flush(&mut self) -> io::Result<()> {
61 pub fn is_ebadf(err: &io::Error) -> bool {
62 err.raw_os_error() == Some(libc::EBADF as i32)
65 pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE;
67 pub fn panic_output() -> Option<impl io::Write> {