From a30a849b78fa4fe8552141b7b2802d1af1b18c09 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 13 Oct 2019 10:36:33 +0200 Subject: Adding upstream version 1.18.0. Signed-off-by: Daniel Baumann --- libnetdata/popen/popen.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libnetdata/popen/popen.c') diff --git a/libnetdata/popen/popen.c b/libnetdata/popen/popen.c index 177aebfc0..906b10535 100644 --- a/libnetdata/popen/popen.c +++ b/libnetdata/popen/popen.c @@ -68,7 +68,7 @@ static inline FILE *custom_popene(const char *command, volatile pid_t *pidptr, c int i; for(i = (int) (sysconf(_SC_OPEN_MAX) - 1); i >= 0; i--) if(i != STDIN_FILENO && i != STDERR_FILENO) - fcntl(i, F_SETFD, FD_CLOEXEC); + (void)fcntl(i, F_SETFD, FD_CLOEXEC); if (!posix_spawn_file_actions_init(&fa)) { // move the pipe to stdout in the child @@ -97,7 +97,7 @@ static inline FILE *custom_popene(const char *command, volatile pid_t *pidptr, c debug(D_CHILDS, "Spawned command: '%s' on pid %d from parent pid %d.", command, pid, getpid()); } else { error("Failed to spawn command: '%s' from parent pid %d.", command, getpid()); - close(pipefd[PIPE_READ]); + fclose(fp); fp = NULL; } close(pipefd[PIPE_WRITE]); @@ -116,7 +116,11 @@ error_after_posix_spawn_file_actions_init: if (posix_spawn_file_actions_destroy(&fa)) error("posix_spawn_file_actions_destroy"); error_after_pipe: - close(pipefd[PIPE_READ]); + if (fp) + fclose(fp); + else + close(pipefd[PIPE_READ]); + close(pipefd[PIPE_WRITE]); return NULL; } -- cgit v1.2.3