From 3a7c0bf6deed91d7ef1993ff5c3366e27d048fcd Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Fri, 12 Nov 2021 21:09:41 +0000 Subject: [PATCH] virgl: use os_dupfd_cloexec from mesa util Signed-off-by: Yiwei Zhang Reviewed-by: Chia-I Wu --- src/virgl_resource.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/virgl_resource.c b/src/virgl_resource.c index 254a6af..25aa68f 100644 --- a/src/virgl_resource.c +++ b/src/virgl_resource.c @@ -30,6 +30,7 @@ #include #include +#include "util/os_file.h" #include "util/u_hash_table.h" #include "util/u_pointer.h" #include "virgl_util.h" @@ -219,13 +220,7 @@ enum virgl_resource_fd_type virgl_resource_export_fd(struct virgl_resource *res, int *fd) { if (res->fd_type != VIRGL_RESOURCE_FD_INVALID) { -#ifdef F_DUPFD_CLOEXEC - *fd = fcntl(res->fd, F_DUPFD_CLOEXEC, 0); - if (*fd < 0) - *fd = dup(res->fd); -#else - *fd = dup(res->fd); -#endif + *fd = os_dupfd_cloexec(res->fd); return *fd >= 0 ? res->fd_type : VIRGL_RESOURCE_FD_INVALID; } else if (res->pipe_resource) { return pipe_callbacks.export_fd(res->pipe_resource,