diff options
author | Lennart Weller <lhw@ring0.de> | 2016-05-25 10:36:27 +0000 |
---|---|---|
committer | Lennart Weller <lhw@ring0.de> | 2016-05-25 10:36:27 +0000 |
commit | 39ecaf8d995e3fefea54f260b8b42bbb9cc806d6 (patch) | |
tree | 02ecee3bf4d7dad9dfad2e1799616716f5ffbf03 /src/popen.c | |
parent | broken logrotate (diff) | |
parent | Imported Upstream version 1.2.0 (diff) | |
download | netdata-39ecaf8d995e3fefea54f260b8b42bbb9cc806d6.tar.xz netdata-39ecaf8d995e3fefea54f260b8b42bbb9cc806d6.zip |
Merge tag 'upstream/1.2.0'
Upstream version 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 882a4cc5a..06f27c0b7 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); } |