diff options
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/state_trackers/egl/drm/native_drm.c | 11 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/fbdev/native_fbdev.c | 11 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/wayland/native_drm.c | 10 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/x11/x11_screen.c | 10 |
4 files changed, 38 insertions, 4 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); diff --git a/src/gallium/state_trackers/egl/fbdev/native_fbdev.c b/src/gallium/state_trackers/egl/fbdev/native_fbdev.c index e126888df90..b45ab5c4f2e 100644 --- a/src/gallium/state_trackers/egl/fbdev/native_fbdev.c +++ b/src/gallium/state_trackers/egl/fbdev/native_fbdev.c @@ -515,7 +515,16 @@ native_create_display(void *dpy, boolean use_sw) /* well, this makes fd 0 being ignored */ if (!dpy) { - fd = open("/dev/fb0", O_RDWR); + const char *device_name="/dev/fb0"; +#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); + } } else { fd = dup((int) pointer_to_intptr(dpy)); diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c b/src/gallium/state_trackers/egl/wayland/native_drm.c index 8daf7830dd4..e3bd628675e 100644 --- a/src/gallium/state_trackers/egl/wayland/native_drm.c +++ b/src/gallium/state_trackers/egl/wayland/native_drm.c @@ -133,7 +133,15 @@ drm_handle_device(void *data, struct wl_drm *drm, const char *device) if (!drmdpy->device_name) return; - drmdpy->fd = open(drmdpy->device_name, O_RDWR); +#ifdef O_CLOEXEC + drmdpy->fd = open(drmdpy->device_name, O_RDWR | O_CLOEXEC); + if (drmdpy->fd == -1 && errno == EINVAL) +#endif + { + drmdpy->fd = open(drmdpy->device_name, O_RDWR); + if (drmdpy->fd != -1) + fcntl(drmdpy->fd, F_SETFD, fcntl(drmdpy->fd, F_GETFD) | FD_CLOEXEC); + } if (drmdpy->fd == -1) { _eglLog(_EGL_WARNING, "wayland-egl: could not open %s (%s)", drmdpy->device_name, strerror(errno)); diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.c b/src/gallium/state_trackers/egl/x11/x11_screen.c index 1e20f941c81..f8f9e2ae767 100644 --- a/src/gallium/state_trackers/egl/x11/x11_screen.c +++ b/src/gallium/state_trackers/egl/x11/x11_screen.c @@ -265,7 +265,15 @@ x11_screen_enable_dri2(struct x11_screen *xscr, if (!x11_screen_probe_dri2(xscr, NULL, NULL)) return -1; - fd = open(xscr->dri_device, O_RDWR); +#ifdef O_CLOEXEC + fd = open(xscr->dri_device, O_RDWR | O_CLOEXEC); + if (fd == -1 && errno == EINVAL) +#endif + { + fd = open(xscr->dri_device, O_RDWR); + if (fd != -1) + fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); + } if (fd < 0) { _eglLog(_EGL_WARNING, "failed to open %s", xscr->dri_device); return -1; |