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_radio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'stream/stream_radio.c') diff --git a/stream/stream_radio.c b/stream/stream_radio.c index 6d07d9738f..5de81c4f90 100644 --- a/stream/stream_radio.c +++ b/stream/stream_radio.c @@ -39,11 +39,14 @@ #include #endif +#include + #include "stream.h" #include "mpvcore/m_option.h" #include "mpvcore/mp_msg.h" #include "stream_radio.h" -#include "libavutil/avstring.h" + +#include "osdep/io.h" #if HAVE_RADIO_CAPTURE #include "audio_in.h" @@ -877,7 +880,7 @@ static int open_s(stream_t *stream,int mode) stream->close=close_s; stream->fill_buffer=fill_buffer_s; - priv->radio_fd = open(priv->radio_param->device, O_RDONLY); + priv->radio_fd = open(priv->radio_param->device, O_RDONLY | O_CLOEXEC); if (priv->radio_fd < 0) { mp_tmsg(MSGT_RADIO, MSGL_ERR, "[radio] Unable to open '%s': %s\n", priv->radio_param->device, strerror(errno)); -- cgit v1.2.3