summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/egl/drm
diff options
context:
space:
mode:
authorDavid Fries <[email protected]>2011-12-10 11:28:45 -0600
committerDave Airlie <[email protected]>2012-03-11 19:05:50 +0000
commitb60120608f6ddf4098bc324363197c979ee04cb7 (patch)
treef3757427a0e19359662ede905bfb90359f5fec2d /src/gallium/state_trackers/egl/drm
parent5ea18503e757ceeb9eba32a72fdf02b7bc710275 (diff)
Set close on exec flag FD_CLOEXEC
Set the close on exec flag when opening dri character devices, so they will be closed and free any resouces allocated in exec. Signed-off-by: David Fries <[email protected]> Reviewed-by: Adam Jackson <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/egl/drm')
-rw-r--r--src/gallium/state_trackers/egl/drm/native_drm.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/egl/drm/native_drm.c b/src/gallium/state_trackers/egl/drm/native_drm.c
index 6ac12100f76..ba7afdbe3b8 100644
--- a/src/gallium/state_trackers/egl/drm/native_drm.c
+++ b/src/gallium/state_trackers/egl/drm/native_drm.c
@@ -312,7 +312,16 @@ native_create_display(void *dpy, boolean use_sw)
gbm = dpy;
if (gbm == NULL) {
- fd = open("/dev/dri/card0", O_RDWR);
+ const char *device_name="/dev/dri/card0";
+#ifdef O_CLOEXEC
+ fd = open(device_name, O_RDWR | O_CLOEXEC);
+ if (fd == -1 && errno == EINVAL)
+#endif
+ {
+ fd = open(device_name, O_RDWR);
+ if (fd != -1)
+ fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
+ }
/* FIXME: Use an internal constructor to create a gbm
* device with gallium backend directly, without setenv */
setenv("GBM_BACKEND", "gbm_gallium_drm.so", 1);