diff options
author | David Fries <David@Fries.net> | 2011-12-10 11:28:45 -0600 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-03-11 19:05:50 +0000 |
commit | b60120608f6ddf4098bc324363197c979ee04cb7 (patch) | |
tree | f3757427a0e19359662ede905bfb90359f5fec2d /src/egl | |
parent | 5ea18503e757ceeb9eba32a72fdf02b7bc710275 (diff) | |
download | external_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')
-rw-r--r-- | src/egl/drivers/dri2/platform_wayland.c | 11 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_x11.c | 9 |
2 files changed, 19 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)); diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index a100f4d..7486a91 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -1083,7 +1083,16 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp) if (!dri2_load_driver(disp)) goto cleanup_conn; +#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, "DRI2: could not open %s (%s)", dri2_dpy->device_name, |