diff options
Diffstat (limited to '')
-rw-r--r-- | libnetdata/popen/popen.c (renamed from src/popen.c) | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/popen.c b/libnetdata/popen/popen.c index eda1c05b9..845363fd2 100644 --- a/src/popen.c +++ b/libnetdata/popen/popen.c @@ -1,4 +1,6 @@ -#include "common.h" +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "../libnetdata.h" /* struct mypopen { @@ -67,7 +69,7 @@ FILE *mypopen(const char *command, volatile pid_t *pidptr) // close all files int i; - for(i = (int) (sysconf(_SC_OPEN_MAX) - 1); i > 0; i--) + for(i = (int) (sysconf(_SC_OPEN_MAX) - 1); i >= 0; i--) if(i != STDIN_FILENO && i != STDERR_FILENO && i != pipefd[PIPE_WRITE]) close(i); // move the pipe to stdout @@ -136,7 +138,7 @@ FILE *mypopene(const char *command, volatile pid_t *pidptr, char **env) { // close all files int i; - for(i = (int) (sysconf(_SC_OPEN_MAX) - 1); i > 0; i--) + for(i = (int) (sysconf(_SC_OPEN_MAX) - 1); i >= 0; i--) if(i != STDIN_FILENO && i != STDERR_FILENO && i != pipefd[PIPE_WRITE]) close(i); // move the pipe to stdout |