summaryrefslogtreecommitdiffstats
path: root/libnetdata/popen
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-10-13 08:36:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-10-13 08:36:33 +0000
commita30a849b78fa4fe8552141b7b2802d1af1b18c09 (patch)
treefab3c8bf29bf2d565595d4fa6a9413916ff02fee /libnetdata/popen
parentAdding upstream version 1.17.1. (diff)
downloadnetdata-a30a849b78fa4fe8552141b7b2802d1af1b18c09.tar.xz
netdata-a30a849b78fa4fe8552141b7b2802d1af1b18c09.zip
Adding upstream version 1.18.0.upstream/1.18.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnetdata/popen')
-rw-r--r--libnetdata/popen/popen.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libnetdata/popen/popen.c b/libnetdata/popen/popen.c
index 177aebfc..906b1053 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;
}