summaryrefslogtreecommitdiffstats
path: root/src/egl/drivers/dri2/platform_wayland.c
diff options
context:
space:
mode:
authorDavid Fries <David@Fries.net>2011-12-10 11:28:45 -0600
committerDave Airlie <airlied@redhat.com>2012-03-11 19:05:50 +0000
commitb60120608f6ddf4098bc324363197c979ee04cb7 (patch)
treef3757427a0e19359662ede905bfb90359f5fec2d /src/egl/drivers/dri2/platform_wayland.c
parent5ea18503e757ceeb9eba32a72fdf02b7bc710275 (diff)
downloadexternal_mesa3d-b60120608f6ddf4098bc324363197c979ee04cb7.zip
external_mesa3d-b60120608f6ddf4098bc324363197c979ee04cb7.tar.gz
external_mesa3d-b60120608f6ddf4098bc324363197c979ee04cb7.tar.bz2
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 <David@Fries.net> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src/egl/drivers/dri2/platform_wayland.c')
-rw-r--r--src/egl/drivers/dri2/platform_wayland.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index ad649b1..0f439c7 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -748,7 +748,16 @@ drm_handle_device(void *data, struct wl_drm *drm, const char *device)
if (!dri2_dpy->device_name)
return;
- dri2_dpy->fd = open(dri2_dpy->device_name, O_RDWR);
+#ifdef O_CLOEXEC
+ dri2_dpy->fd = open(dri2_dpy->device_name, O_RDWR | O_CLOEXEC);
+ if (dri2_dpy->fd == -1 && errno == EINVAL)
+#endif
+ {
+ dri2_dpy->fd = open(dri2_dpy->device_name, O_RDWR);
+ if (dri2_dpy->fd != -1)
+ fcntl(dri2_dpy->fd, F_SETFD, fcntl(dri2_dpy->fd, F_GETFD) |
+ FD_CLOEXEC);
+ }
if (dri2_dpy->fd == -1) {
_eglLog(_EGL_WARNING, "wayland-egl: could not open %s (%s)",
dri2_dpy->device_name, strerror(errno));