From 154d771692a1ca9b9af5eb0acc12885ca852307a Mon Sep 17 00:00:00 2001 From: Chris Rankin Date: Mon, 3 Oct 2011 01:34:37 +0100 Subject: Mark simple file and socket descriptors as uninheritable. This patch creates two utility functions: int open_cloexec(pathname, flags) int create_cloexec(pathname, flags, mode) These return a file descriptor with the CLOEXEC flag set, to ensure that the descriptor is not inherited across a fork/exec operation. The sockets returned by: _x_io_tcp_connect_ipv4() _x_io_tcp_connect() now also have their CLOEXEC flag set. --- src/input/input_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/input/input_file.c') diff --git a/src/input/input_file.c b/src/input/input_file.c index ee8957894..f9232b389 100644 --- a/src/input/input_file.c +++ b/src/input/input_file.c @@ -359,7 +359,7 @@ static int file_plugin_open (input_plugin_t *this_gen ) { else filename = strdup(this->mrl); /* NEVER unescape plain file names! */ - this->fh = open (filename, O_RDONLY|O_BINARY); + this->fh = open_cloexec(filename, O_RDONLY|O_BINARY); if (this->fh == -1) { if (errno == EACCES) { -- cgit v1.2.3