Don't duplicate file descriptors into stdio fds

This commit is contained in:
beetrees 2022-09-04 10:22:36 +01:00
parent c2d140bd36
commit 0e0756cf0d
No known key found for this signature in database
GPG Key ID: 8791BD754191EBD6

View File

@ -104,7 +104,8 @@ impl BorrowedFd<'_> {
#[cfg(target_os = "espidf")]
let cmd = libc::F_DUPFD;
let fd = cvt(unsafe { libc::fcntl(self.as_raw_fd(), cmd, 0) })?;
// Avoid using file descriptors below 3 as they are used for stdio
let fd = cvt(unsafe { libc::fcntl(self.as_raw_fd(), cmd, 3) })?;
Ok(unsafe { OwnedFd::from_raw_fd(fd) })
}