From e3af0032b236dc52d4a74c4d740e57a1f6d520aa Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 7 Nov 2009 18:55:16 +0100 Subject: set the close-on-exec flag on all file descriptors Added the "fd_util" library, which attempts to use the new thread-safe Linux system calls pipe2(), accept4() and the options O_CLOEXEC, SOCK_CLOEXEC. Without these, it falls back to FD_CLOEXEC, which is not thread safe. This is particularly important for the "pipe" output plugin (and others, such as JACK/PulseAudio), because we were heavily leaking file descriptors to child processes. --- src/input/file_input_plugin.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/input') diff --git a/src/input/file_input_plugin.c b/src/input/file_input_plugin.c index 07c1e4ed6..55b495f38 100644 --- a/src/input/file_input_plugin.c +++ b/src/input/file_input_plugin.c @@ -20,6 +20,7 @@ #include "config.h" /* must be first for large file support */ #include "input/file_input_plugin.h" #include "input_plugin.h" +#include "fd_util.h" #include #include @@ -50,7 +51,7 @@ input_file_open(struct input_stream *is, const char *filename) *slash = '\0'; } - fd = open(pathname, O_RDONLY); + fd = open_cloexec(pathname, O_RDONLY); if (fd < 0) { is->error = errno; g_debug("Failed to open \"%s\": %s", -- cgit v1.2.3