cros_async: Use fcntl instead of dup

dup doesn't allow us to pass in the CLOEXEC flag.

BUG=none
TEST=unit tests

Change-Id: Ia8572fa42b853e50773c80f22ec0a598e940fe48
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2629148
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
This commit is contained in:
Chirantan Ekbote 2021-01-14 19:14:30 +09:00 committed by Commit Bot
parent d8dd1c62c7
commit 4223a41932
2 changed files with 2 additions and 2 deletions

View file

@ -279,7 +279,7 @@ impl<T: FutureList> Drop for FdExecutor<T> {
// Used to `dup` the FDs passed to the executor so there is a guarantee they aren't closed while
// waiting in TLS to be added to the main polling context.
unsafe fn dup_fd(fd: RawFd) -> Result<RawFd> {
let ret = libc::dup(fd);
let ret = libc::fcntl(fd, libc::F_DUPFD_CLOEXEC, 0);
if ret < 0 {
Err(Error::DuplicatingFd(sys_util::Error::last()))
} else {

View file

@ -677,7 +677,7 @@ impl<T: FutureList> Drop for URingExecutor<T> {
// Used to dup the FDs passed to the executor so there is a guarantee they aren't closed while
// waiting in TLS to be added to the main polling context.
unsafe fn dup_fd(fd: RawFd) -> Result<RawFd> {
let ret = libc::dup(fd);
let ret = libc::fcntl(fd, libc::F_DUPFD_CLOEXEC, 0);
if ret < 0 {
Err(Error::DuplicatingFd(sys_util::Error::last()))
} else {