Skip to content

Commit 0e0756c

Browse files
committed
Don't duplicate file descriptors into stdio fds
1 parent c2d140b commit 0e0756c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/std/src/os/fd/owned.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ impl BorrowedFd<'_> {
104104
#[cfg(target_os = "espidf")]
105105
let cmd = libc::F_DUPFD;
106106

107-
let fd = cvt(unsafe { libc::fcntl(self.as_raw_fd(), cmd, 0) })?;
107+
// Avoid using file descriptors below 3 as they are used for stdio
108+
let fd = cvt(unsafe { libc::fcntl(self.as_raw_fd(), cmd, 3) })?;
108109
Ok(unsafe { OwnedFd::from_raw_fd(fd) })
109110
}
110111

0 commit comments

Comments
 (0)