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.
This commit is contained in:
@@ -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 <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
@@ -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",
|
||||
|
Reference in New Issue
Block a user