[Mesa-dev] [PATCH 2/5] i965: replace calls to dup(2) with fcntl(F_DUPFD_CLOEXEC)
Matt Whitlock
freedesktop at mattwhitlock.name
Tue Mar 27 00:57:30 UTC 2018
Without this fix, duplicated file descriptors leak into child processes.
See commit aaac913e901229d11a1894f6aaf646de6b1a542c for one instance
where the same fix was employed.
Signed-off-by: Matt Whitlock <freedesktop at mattwhitlock.name>
---
src/mesa/drivers/dri/i965/brw_sync.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_sync.c b/src/mesa/drivers/dri/i965/brw_sync.c
index 6391648879..98abab03b7 100644
--- a/src/mesa/drivers/dri/i965/brw_sync.c
+++ b/src/mesa/drivers/dri/i965/brw_sync.c
@@ -502,7 +502,7 @@ brw_dri_create_fence_fd(__DRIcontext *dri_ctx, int fd)
goto fail;
} else {
/* Import the sync fd as an in-fence. */
- fence->sync_fd = dup(fd);
+ fence->sync_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
}
assert(fence->sync_fd != -1);
@@ -519,7 +519,7 @@ static int
brw_dri_get_fence_fd_locked(struct brw_fence *fence)
{
assert(fence->type == BRW_FENCE_TYPE_SYNC_FD);
- return dup(fence->sync_fd);
+ return fcntl(fence->sync_fd, F_DUPFD_CLOEXEC, 3);
}
static int
--
2.16.3
More information about the mesa-dev
mailing list