From 3c7957089c31e706b488056e2124a753e31365f7 Mon Sep 17 00:00:00 2001 From: Arne Juul Date: Mon, 9 Oct 2017 10:57:19 +0000 Subject: use vespalib::SignalHandler --- configd/src/apps/sentinel/service.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'configd/src/apps/sentinel/service.cpp') diff --git a/configd/src/apps/sentinel/service.cpp b/configd/src/apps/sentinel/service.cpp index fc1f768f989..2f13a05eb4f 100644 --- a/configd/src/apps/sentinel/service.cpp +++ b/configd/src/apps/sentinel/service.cpp @@ -3,6 +3,7 @@ #include "service.h" #include "output-connection.h" #include +#include #include #include @@ -13,7 +14,11 @@ LOG_SETUP(".service"); #include -extern sig_atomic_t stop; +static bool stop() +{ + return (vespalib::SignalHandler::INT.check() || + vespalib::SignalHandler::TERM.check()); +} using vespalib::make_string; @@ -212,7 +217,7 @@ Service::start() static_cast(getpid())); signal(SIGTERM, SIG_DFL); signal(SIGINT, SIG_DFL); - if (stop) { + if (stop()) { kill(getpid(), SIGTERM); } if (_restartPenalty > 0) { @@ -315,7 +320,7 @@ Service::youExited(int status) } else if (_state == KILLING) { setState(KILLED); } - if (_isAutomatic && _config->autorestart && !stop) { + if (_isAutomatic && _config->autorestart && !stop()) { // ### Implement some rate limiting here maybe? LOG(debug, "%s: Has autorestart flag, restarting.", name().c_str()); setState(READY); -- cgit v1.2.3