summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-05-04 22:31:28 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-05-04 22:31:28 +0200
commit7c9b068f37971ae1b5f923ea4541e31a5a5117c8 (patch)
tree512ed65a959892c3066ca0af2725dc54743ec74e
parentf081cd75a4296f1f99b5a35ddf5b2ca5fe5d64d6 (diff)
Use CLOEXEC for all fd's
-rw-r--r--src/wfddevice.c9
-rw-r--r--src/wfdevent.c6
2 files changed, 11 insertions, 4 deletions
diff --git a/src/wfddevice.c b/src/wfddevice.c
index f3ccc83..5fa710b 100644
--- a/src/wfddevice.c
+++ b/src/wfddevice.c
@@ -20,6 +20,8 @@
* THE SOFTWARE.
*/
+#define _GNU_SOURCE
+
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
@@ -82,7 +84,7 @@ open_from_syspath(struct udev *udev, const char *syspath)
if (device == NULL)
return -1;
- fd = open(udev_device_get_devnode(device), O_RDWR);
+ fd = open(udev_device_get_devnode(device), O_RDWR | O_CLOEXEC);
udev_device_unref(device);
@@ -124,7 +126,8 @@ enumerate_devices(struct wfd_registry *registry)
continue;
} else if (registry->devices[i].fd == 0) {
int tmp;
- tmp = dup(registry->devices[i].fd);
+ tmp = fcntl(registry->devices[i].fd,
+ F_DUPFD_CLOEXEC, 0);
close(registry->devices[i].fd);
registry->devices[i].fd = tmp;
}
@@ -226,7 +229,7 @@ wfd_create_device(WFDint device_id, const WFDint *attrib_list)
device->error = WFD_ERROR_NONE;
device->choosen_crtcs = 0;
- device->fd = dup(device_id);
+ device->fd = fcntl(device_id, F_DUPFD_CLOEXEC, 0);
if (device->fd < 0)
goto cleanup_device;
diff --git a/src/wfdevent.c b/src/wfdevent.c
index f729936..bca6a45 100644
--- a/src/wfdevent.c
+++ b/src/wfdevent.c
@@ -20,6 +20,8 @@
* THE SOFTWARE.
*/
+#define _GNU_SOURCE
+
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
@@ -42,6 +44,7 @@
#include <sys/eventfd.h>
#include <sys/time.h>
#include <unistd.h>
+#include <fcntl.h>
struct bind_event {
WFDint pipeline_id;
@@ -133,7 +136,8 @@ wfd_event_update(struct wfd_device *device,
if (additions & WFD_EVENT_PIPELINE_BIND_SOURCE_COMPLETE_MASK) {
memset(&ep, 0, sizeof ep);
ep.events = EPOLLIN;
- event->drm_fd = dup(wfd_device_get_fd(device));
+ event->drm_fd = fcntl(wfd_device_get_fd(device),
+ F_DUPFD_CLOEXEC, 0);
if (event->drm_fd < 0) {
fprintf(stderr, "failed to dup drm fd: %m\n");
return -1;