Skip to content

Commit

Permalink
Don't duplicate file descriptors into stdio fds
Browse files Browse the repository at this point in the history
  • Loading branch information
beetrees committed Sep 4, 2022
1 parent c2d140b commit 0e0756c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion library/std/src/os/fd/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) })
}

Expand Down

0 comments on commit 0e0756c

Please sign in to comment.