diff options
author | wm4 <wm4@nowhere> | 2013-11-30 22:40:51 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-30 22:40:51 +0100 |
commit | 95cfe58e3db9d939abe7a9a26116c1d576eed60b (patch) | |
tree | 98a4738f2f989c900702d84ef8a257f9413389af /stream/stream_file.c | |
parent | eea69682a6a874d540f9fc576c937466970713f6 (diff) | |
download | mpv-95cfe58e3db9d939abe7a9a26116c1d576eed60b.tar.bz2 mpv-95cfe58e3db9d939abe7a9a26116c1d576eed60b.tar.xz |
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.
Diffstat (limited to 'stream/stream_file.c')
-rw-r--r-- | stream/stream_file.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/stream/stream_file.c b/stream/stream_file.c index b638fdddf0..e72355d387 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -101,11 +101,11 @@ static int open_f(stream_t *stream, int mode) }; stream->priv = priv; - mode_t m = 0; + mode_t m = O_CLOEXEC; if (mode == STREAM_READ) - m = O_RDONLY; + m |= O_RDONLY; else if (mode == STREAM_WRITE) - m = O_RDWR | O_CREAT | O_TRUNC; + m |= O_RDWR | O_CREAT | O_TRUNC; else { mp_msg(MSGT_OPEN, MSGL_ERR, "[file] Unknown open mode %d\n", mode); return STREAM_UNSUPPORTED; |