diff options
author | Lennart Weller <lhw@ring0.de> | 2016-05-25 10:36:24 +0000 |
---|---|---|
committer | Lennart Weller <lhw@ring0.de> | 2016-05-25 10:36:24 +0000 |
commit | b4f64f72a3e4bf590c60b0cbd6cd365aa1a58542 (patch) | |
tree | e6706c727a1fedb44da614453ad3e429a7403a9b /src/popen.c | |
parent | Imported Upstream version 1.1.0 (diff) | |
download | netdata-b4f64f72a3e4bf590c60b0cbd6cd365aa1a58542.tar.xz netdata-b4f64f72a3e4bf590c60b0cbd6cd365aa1a58542.zip |
Imported Upstream version 1.2.0upstream/1.2.0
Diffstat (limited to 'src/popen.c')
-rw-r--r-- | src/popen.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/popen.c b/src/popen.c index 882a4cc5..06f27c0b 100644 --- a/src/popen.c +++ b/src/popen.c @@ -114,10 +114,27 @@ FILE *mypopen(const char *command, pid_t *pidptr) #endif // reset all signals - for (i = 1 ; i < 65 ;i++) if(i != SIGSEGV) signal(i, SIG_DFL); + { + sigset_t sigset; + sigfillset(&sigset); + + if(pthread_sigmask(SIG_UNBLOCK, &sigset, NULL) == -1) { + error("Could not block signals for threads"); + } + // We only need to reset ignored signals. + // Signals with signal handlers are reset by default. + struct sigaction sa; + sigemptyset(&sa.sa_mask); + sa.sa_handler = SIG_DFL; + sa.sa_flags = 0; + if(sigaction(SIGPIPE, &sa, NULL) == -1) { + error("Failed to change signal handler for SIGTERM"); + } + } + info("executing command: '%s' on pid %d.", command, getpid()); - execl("/bin/sh", "sh", "-c", command, NULL); + execl("/bin/sh", "sh", "-c", command, NULL); exit(1); } |