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. --- audio/filter/af_export.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'audio') diff --git a/audio/filter/af_export.c b/audio/filter/af_export.c index c6f745ed50..e1c5c34e19 100644 --- a/audio/filter/af_export.c +++ b/audio/filter/af_export.c @@ -39,6 +39,8 @@ #include #include +#include "osdep/io.h" + #include "talloc.h" #include "af.h" #include "mpvcore/path.h" @@ -107,7 +109,7 @@ static int control(struct af_instance* af, int cmd, void* arg) } // Init memory mapping - s->fd = open(s->filename, O_RDWR | O_CREAT | O_TRUNC, 0640); + s->fd = open(s->filename, O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0640); mp_msg(MSGT_AFILTER, MSGL_INFO, "[export] Exporting to file: %s\n", s->filename); if(s->fd < 0) { mp_msg(MSGT_AFILTER, MSGL_FATAL, "[export] Could not open/create file: %s\n", -- cgit v1.2.3