std::sys::unix::stdio: explain why we do into_raw
This commit is contained in:
@@ -12,7 +12,7 @@ impl Stdin {
|
|||||||
pub fn read(&self, data: &mut [u8]) -> io::Result<usize> {
|
pub fn read(&self, data: &mut [u8]) -> io::Result<usize> {
|
||||||
let fd = FileDesc::new(libc::STDIN_FILENO);
|
let fd = FileDesc::new(libc::STDIN_FILENO);
|
||||||
let ret = fd.read(data);
|
let ret = fd.read(data);
|
||||||
fd.into_raw();
|
fd.into_raw(); // do not close this FD
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ impl Stdout {
|
|||||||
pub fn write(&self, data: &[u8]) -> io::Result<usize> {
|
pub fn write(&self, data: &[u8]) -> io::Result<usize> {
|
||||||
let fd = FileDesc::new(libc::STDOUT_FILENO);
|
let fd = FileDesc::new(libc::STDOUT_FILENO);
|
||||||
let ret = fd.write(data);
|
let ret = fd.write(data);
|
||||||
fd.into_raw();
|
fd.into_raw(); // do not close this FD
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ impl Stderr {
|
|||||||
pub fn write(&self, data: &[u8]) -> io::Result<usize> {
|
pub fn write(&self, data: &[u8]) -> io::Result<usize> {
|
||||||
let fd = FileDesc::new(libc::STDERR_FILENO);
|
let fd = FileDesc::new(libc::STDERR_FILENO);
|
||||||
let ret = fd.write(data);
|
let ret = fd.write(data);
|
||||||
fd.into_raw();
|
fd.into_raw(); // do not close this FD
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user