From 95cfe58e3db9d939abe7a9a26116c1d576eed60b Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 30 Nov 2013 22:40:51 +0100 Subject: Use O_CLOEXEC when creating FDs This is needed so that new processes (created with fork+exec) don't inherit open files, which can be important for a number of reasons. Since O_CLOEXEC is relatively new (POSIX.1-2008, before that Linux specific), we #define it to 0 in io.h to prevent compilation errors on older/crappy systems. At least this is the plan. input.c creates a pipe. For that, add a mp_set_cloexec() function (which is based on Weston's code in vo_wayland.c, but more correct). We could use pipe2() instead, but that is Linux specific. Technically, we have a race condition, but it won't matter. --- stream/stream_pvr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'stream/stream_pvr.c') diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c index 4f121f0853..a89e70b2c6 100644 --- a/stream/stream_pvr.c +++ b/stream/stream_pvr.c @@ -42,6 +42,8 @@ #include #include +#include "osdep/io.h" + #include "mpvcore/mp_msg.h" #include "stream.h" @@ -1579,7 +1581,7 @@ pvr_stream_open (stream_t *stream, int mode) parse_encoder_options (pvr); /* open device */ - pvr->dev_fd = open (pvr->video_dev, O_RDWR); + pvr->dev_fd = open (pvr->video_dev, O_RDWR | O_CLOEXEC); mp_msg (MSGT_OPEN, MSGL_INFO, "%s Using device %s\n", LOG_LEVEL_PVR, pvr->video_dev); if (pvr->dev_fd == -1) -- cgit v1.2.3