summaryrefslogtreecommitdiffstats
path: root/src/glx/dri2_glx.c
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/glx/dri2_glx.c
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/glx/dri2_glx.c')
-rw-r--r--src/glx/dri2_glx.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index b09606addde..b6988c3ca60 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -1045,7 +1045,15 @@ dri2CreateScreen(int screen, struct glx_display * priv)
goto handle_error;
}
- psc->fd = open(deviceName, O_RDWR);
+#ifdef O_CLOEXEC
+ psc->fd = open(deviceName, O_RDWR | O_CLOEXEC);
+ if (psc->fd == -1 && errno == EINVAL)
+#endif
+ {
+ psc->fd = open(deviceName, O_RDWR);
+ if (psc->fd != -1)
+ fcntl(psc->fd, F_SETFD, fcntl(psc->fd, F_GETFD) | FD_CLOEXEC);
+ }
if (psc->fd < 0) {
ErrorMessageF("failed to open drm device: %s\n", strerror(errno));
goto handle_error;