Add fcntl
This commit is contained in:
@@ -49,13 +49,19 @@ impl FileDesc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_cloexec(&self) -> io::Result<()> {
|
pub fn set_cloexec(&self) -> io::Result<()> {
|
||||||
::sys_common::util::dumb_print(format_args!("{}: set cloexec\n", self.fd));
|
let mut flags = cvt(libc::fcntl(self.fd, libc::F_GETFL, 0))?;
|
||||||
unimplemented!();
|
flags |= libc::O_CLOEXEC;
|
||||||
|
cvt(libc::fcntl(self.fd, libc::F_SETFL, flags)).and(Ok(()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_nonblocking(&self, _nonblocking: bool) -> io::Result<()> {
|
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
|
||||||
::sys_common::util::dumb_print(format_args!("{}: set nonblocking\n", self.fd));
|
let mut flags = cvt(libc::fcntl(self.fd, libc::F_GETFL, 0))?;
|
||||||
unimplemented!();
|
if nonblocking {
|
||||||
|
flags |= libc::O_NONBLOCK;
|
||||||
|
} else {
|
||||||
|
flags &= !libc::O_NONBLOCK;
|
||||||
|
}
|
||||||
|
cvt(libc::fcntl(self.fd, libc::F_SETFL, flags)).and(Ok(()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn duplicate(&self) -> io::Result<FileDesc> {
|
pub fn duplicate(&self) -> io::Result<FileDesc> {
|
||||||
|
|||||||
Reference in New Issue
Block a user