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/cookies.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stream/cookies.c') diff --git a/stream/cookies.c b/stream/cookies.c index e0cfca7681..b5815da6e5 100644 --- a/stream/cookies.c +++ b/stream/cookies.c @@ -99,7 +99,7 @@ static char *load_file(const char *filename, int64_t * length) mp_msg(MSGT_NETWORK, MSGL_V, "Loading cookie file: %s\n", filename); - fd = open(filename, O_RDONLY); + fd = open(filename, O_RDONLY | O_CLOEXEC); if (fd < 0) { mp_msg(MSGT_NETWORK, MSGL_V, "Could not open"); goto err_out; -- cgit v1.2.3