[Mesa-dev] [PATCH 1/2] egl/drm: set CLOEXEC on fd after dup()

Derek Foreman derekf at osg.samsung.com
Fri Jun 12 12:07:09 PDT 2015


Prevents fd leak if the caller forks later.

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 src/egl/drivers/dri2/platform_drm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 3391afc..5c356c4 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -637,6 +637,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
          free(dri2_dpy);
          return EGL_FALSE;
       }
+      fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
    }
 
    dri2_dpy->fd = fd;
-- 
2.1.4



More information about the mesa-dev mailing list