X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fpopen.c;h=8448b7311d18049b185f686b2b92a2abb00fa527;hb=f5fef72a72cfc1c799b7a9b37ff2dfa25e731420;hp=eee08b5ed9010fe6532625bf6d3e0cc969feffc9;hpb=1dfe07df975a513a7761efe179425bfcd4804c71;p=netdata.git diff --git a/src/popen.c b/src/popen.c index eee08b5e..8448b731 100644 --- a/src/popen.c +++ b/src/popen.c @@ -118,16 +118,27 @@ FILE *mypopen(const char *command, pid_t *pidptr) sigemptyset(&sa.sa_mask); sa.sa_handler = SIG_DFL; sa.sa_flags = 0; - - if(sigaction(SIGUSR1, &sa, NULL) == -1) - error("pre-execution of command '%s' on pid %d: failed to set default signal handler for SIGUSR1.", command, getpid()); + + if(sigaction(SIGINT, &sa, NULL) == -1) + error("pre-execution of command '%s' on pid %d: failed to set default signal handler for SIGINT.", command, getpid()); + + if(sigaction(SIGTERM, &sa, NULL) == -1) + error("pre-execution of command '%s' on pid %d: failed to set default signal handler for SIGTERM.", command, getpid()); if(sigaction(SIGPIPE, &sa, NULL) == -1) error("pre-execution of command '%s' on pid %d: failed to set default signal handler for SIGPIPE.", command, getpid()); - } + if(sigaction(SIGHUP, &sa, NULL) == -1) + error("pre-execution of command '%s' on pid %d: failed to set default signal handler for SIGHUP.", command, getpid()); - info("executing command: '%s' on pid %d.", command, getpid()); + if(sigaction(SIGUSR1, &sa, NULL) == -1) + error("pre-execution of command '%s' on pid %d: failed to set default signal handler for SIGUSR1.", command, getpid()); + + if(sigaction(SIGUSR2, &sa, NULL) == -1) + error("pre-execution of command '%s' on pid %d: failed to set default signal handler for SIGUSR2.", command, getpid()); + } + + debug(D_CHILDS, "executing command: '%s' on pid %d.", command, getpid()); execl("/bin/sh", "sh", "-c", command, NULL); exit(1); } @@ -136,6 +147,13 @@ int mypclose(FILE *fp, pid_t pid) { debug(D_EXIT, "Request to mypclose() on pid %d", pid); /*mypopen_del(fp);*/ + + // close the pipe fd + // this is required in musl + // without it the childs do not exit + close(fileno(fp)); + + // close the pipe file pointer fclose(fp); siginfo_t info;