summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <git@arunraghavan.net>2015-11-03 22:01:07 +0530
committerTim-Philipp Müller <tim@centricular.com>2015-11-05 00:26:02 +0000
commitccc4d0cc7fb1ea0774e9ad33731f9036a38790bf (patch)
treee66cddb33b2b731fe203976a0d8d7ca604170f02
parentfd940f6b7a8c91f2a405a16d573fe199ca7a3162 (diff)
downloadgstreamer-plugins-good-ccc4d0cc7fb1ea0774e9ad33731f9036a38790bf.tar.gz
v4l2: Set O_CLOEXEC on the device fd
This is needed to make sure that child processes don't inherit the video device fd which can cause problems with some drivers.
-rw-r--r--sys/v4l2/gstv4l2.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/v4l2/gstv4l2.c b/sys/v4l2/gstv4l2.c
index 08ff3f582..8333eab41 100644
--- a/sys/v4l2/gstv4l2.c
+++ b/sys/v4l2/gstv4l2.c
@@ -25,6 +25,10 @@
#include "config.h"
#endif
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE /* O_CLOEXEC */
+#endif
+
#include "gst/gst-i18n-plugin.h"
#include <gst/gst.h>
@@ -124,7 +128,8 @@ gst_v4l2_probe_and_register (GstPlugin * plugin)
if (video_fd >= 0)
close (video_fd);
- video_fd = open (it->device_path, O_RDWR);
+ video_fd = open (it->device_path, O_RDWR | O_CLOEXEC);
+
if (video_fd == -1) {
GST_DEBUG ("Failed to open %s: %s", it->device_path, g_strerror (errno));
continue;