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,