diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-10-26 08:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-10-26 08:29:10 +0000 |
commit | 66ae4baad173098544603718e9864f0da1c0c7a3 (patch) | |
tree | d8e6f387ee9b4d9b6936e3c21208e50b86daea60 /daemon/main.c | |
parent | Adding upstream version 1.18.0. (diff) | |
download | netdata-66ae4baad173098544603718e9864f0da1c0c7a3.tar.xz netdata-66ae4baad173098544603718e9864f0da1c0c7a3.zip |
Adding upstream version 1.18.1.upstream/1.18.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'daemon/main.c')
-rw-r--r-- | daemon/main.c | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/daemon/main.c b/daemon/main.c index 4189ac7bd..0e56654db 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -146,46 +146,28 @@ void web_server_config_options(void) { } -int killpid(pid_t pid, int signal) -{ - int ret = -1; +// killpid kills pid with SIGTERM. +int killpid(pid_t pid) { + int ret; debug(D_EXIT, "Request to kill pid %d", pid); errno = 0; - if(kill(pid, 0) == -1) { + ret = kill(pid, SIGTERM); + if (ret == -1) { switch(errno) { case ESRCH: - error("Request to kill pid %d, but it is not running.", pid); - break; + // We wanted the process to exit so just let the caller handle. + return ret; case EPERM: - error("Request to kill pid %d, but I do not have enough permissions.", pid); + error("Cannot kill pid %d, but I do not have enough permissions.", pid); break; default: - error("Request to kill pid %d, but I received an error.", pid); + error("Cannot kill pid %d, but I received an error.", pid); break; } } - else { - errno = 0; - ret = kill(pid, signal); - if(ret == -1) { - switch(errno) { - case ESRCH: - error("Cannot kill pid %d, but it is not running.", pid); - break; - - case EPERM: - error("Cannot kill pid %d, but I do not have enough permissions.", pid); - break; - - default: - error("Cannot kill pid %d, but I received an error.", pid); - break; - } - } - } return ret; } |