[Mesa-dev] [PATCH 1/5] egl/dri2: replace call to dup(2) with fcntl(F_DUPFD_CLOEXEC)

Matt Whitlock freedesktop at mattwhitlock.name
Tue Mar 27 00:57:29 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/egl/drivers/dri2/egl_dri2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 45d0c7275c..f1919da3a0 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -3028,7 +3028,7 @@ dri2_dup_native_fence_fd(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync)
       return EGL_NO_NATIVE_FENCE_FD_ANDROID;
    }
 
-   return dup(sync->SyncFd);
+   return fcntl(sync->SyncFd, F_DUPFD_CLOEXEC, 3);
 }
 
 static void
-- 
2.16.3



More information about the mesa-dev mailing list