Move stdout/err flush into sys

This commit is contained in:
Jeremy Soller
2016-11-28 18:25:47 -07:00
parent 2ec21327f2
commit 1d0bba8224
4 changed files with 25 additions and 9 deletions

View File

@@ -81,16 +81,10 @@ impl Read for StdinRaw {
}
impl Write for StdoutRaw {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { self.0.write(buf) }
#[cfg(not(target_os = "redox"))]
fn flush(&mut self) -> io::Result<()> { Ok(()) }
#[cfg(target_os = "redox")]
fn flush(&mut self) -> io::Result<()> { self.0.flush() }
}
impl Write for StderrRaw {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { self.0.write(buf) }
#[cfg(not(target_os = "redox"))]
fn flush(&mut self) -> io::Result<()> { Ok(()) }
#[cfg(target_os = "redox")]
fn flush(&mut self) -> io::Result<()> { self.0.flush() }
}

View File

@@ -73,7 +73,7 @@ impl io::Write for Stderr {
}
fn flush(&mut self) -> io::Result<()> {
cvt(syscall::fsync(2)).and(Ok(()))
Stderr::flush(self)
}
}

View File

@@ -43,6 +43,10 @@ impl Stdout {
fd.into_raw();
ret
}
pub fn flush(&self) -> io::Result<()> {
Ok(())
}
}
impl Stderr {
@@ -54,6 +58,10 @@ impl Stderr {
fd.into_raw();
ret
}
pub fn flush(&self) -> io::Result<()> {
Ok(())
}
}
// FIXME: right now this raw stderr handle is used in a few places because
@@ -63,7 +71,10 @@ impl io::Write for Stderr {
fn write(&mut self, data: &[u8]) -> io::Result<usize> {
Stderr::write(self, data)
}
fn flush(&mut self) -> io::Result<()> { Ok(()) }
fn flush(&mut self) -> io::Result<()> {
Stderr::flush(self)
}
}
pub const EBADF_ERR: i32 = ::libc::EBADF as i32;

View File

@@ -156,6 +156,10 @@ impl Stdout {
pub fn write(&self, data: &[u8]) -> io::Result<usize> {
write(&self.0, data)
}
pub fn flush(&self) -> io::Result<()> {
Ok(())
}
}
impl Stderr {
@@ -166,6 +170,10 @@ impl Stderr {
pub fn write(&self, data: &[u8]) -> io::Result<usize> {
write(&self.0, data)
}
pub fn flush(&self) -> io::Result<()> {
Ok(())
}
}
// FIXME: right now this raw stderr handle is used in a few places because
@@ -175,7 +183,10 @@ impl io::Write for Stderr {
fn write(&mut self, data: &[u8]) -> io::Result<usize> {
Stderr::write(self, data)
}
fn flush(&mut self) -> io::Result<()> { Ok(()) }
fn flush(&mut self) -> io::Result<()> {
Stderr::flush(self)
}
}
impl NoClose {