summaryrefslogtreecommitdiffstats
path: root/logd/src/apps/logd/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'logd/src/apps/logd/main.cpp')
-rw-r--r--logd/src/apps/logd/main.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/logd/src/apps/logd/main.cpp b/logd/src/apps/logd/main.cpp
index caeaf83c7cc..00654060107 100644
--- a/logd/src/apps/logd/main.cpp
+++ b/logd/src/apps/logd/main.cpp
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <logd/errhandle.h>
-#include <logd/sigterm.h>
#include <logd/service.h>
#include <logd/forward.h>
#include <logd/conf.h>
@@ -9,6 +8,7 @@
#include <vespa/config/common/exceptions.h>
#include <csignal>
#include <unistd.h>
+#include <vespa/vespalib/util/sig_catch.h>
#include <vespa/log/log.h>
LOG_SETUP("logdemon");
@@ -24,7 +24,7 @@ int main(int, char**)
EV_STARTED("logdemon");
- hook_signals();
+ vespalib::SigCatch catcher;
const char *cfid = getenv("VESPA_CONFIG_ID");
@@ -50,7 +50,7 @@ int main(int, char**)
LOG(debug, "connection exception: %s", ex.what());
subscriber.closeConn();
}
- if (gotSignaled()) {
+ if (catcher.receivedStopSignal()) {
throw SigTermException("caught signal");
}
if (sleepcount < 60) {
@@ -60,10 +60,10 @@ int main(int, char**)
}
LOG(debug, "sleep %d...", sleepcount);
for (int i = 0; i < sleepcount; i++) {
- sleep(1);
- if (gotSignaled()) {
- throw SigTermException("caught signal");
- }
+ sleep(1);
+ if (catcher.receivedStopSignal()) {
+ throw SigTermException("caught signal");
+ }
}
}
} catch (config::ConfigRuntimeException & ex) {
@@ -75,15 +75,8 @@ int main(int, char**)
EV_STOPPING("logdemon", "bad config");
return 1;
} catch (SigTermException& ex) {
- if (gotSignalNumber() == SIGTERM) {
- LOG(debug, "stopping on SIGTERM");
- EV_STOPPING("logdemon", "done ok.");
- } else {
- LOG(warning, "stopping on signal %d", gotSignalNumber());
- char buf[100];
- snprintf(buf, sizeof buf, "got signal %d", gotSignalNumber());
- EV_STOPPING("logdemon", buf);
- }
+ LOG(debug, "stopping on SIGTERM");
+ EV_STOPPING("logdemon", "done ok.");
return 0;
} catch (MsgException& ex) {
LOG(error, "stopping on error: %s", ex.what());