aboutsummaryrefslogtreecommitdiffstats
path: root/logforwarder
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2017-10-05 11:41:51 +0000
committerArne Juul <arnej@yahoo-inc.com>2017-10-05 11:41:51 +0000
commitd6267b2b9aff7fcc1d3bf55703501ab5c6484f20 (patch)
tree635933abe0dd1369e8499f89a26ab11d5dd1c5bf /logforwarder
parent4c76bd6a4349b59865a9607fe11fc7177775e1bb (diff)
use vespalib::SigCatch
Diffstat (limited to 'logforwarder')
-rw-r--r--logforwarder/src/apps/vespa-logforwarder-start/CMakeLists.txt2
-rw-r--r--logforwarder/src/apps/vespa-logforwarder-start/main.cpp4
-rw-r--r--logforwarder/src/apps/vespa-logforwarder-start/sig-catch.cpp41
-rw-r--r--logforwarder/src/apps/vespa-logforwarder-start/sig-catch.h8
4 files changed, 3 insertions, 52 deletions
diff --git a/logforwarder/src/apps/vespa-logforwarder-start/CMakeLists.txt b/logforwarder/src/apps/vespa-logforwarder-start/CMakeLists.txt
index f26edd8eee8..9a402bb58da 100644
--- a/logforwarder/src/apps/vespa-logforwarder-start/CMakeLists.txt
+++ b/logforwarder/src/apps/vespa-logforwarder-start/CMakeLists.txt
@@ -3,10 +3,10 @@ vespa_add_executable(logforwarder-start_app
SOURCES
main.cpp
cf-handler.cpp
- sig-catch.cpp
OUTPUT_NAME vespa-logforwarder-start
INSTALL bin
DEPENDS
config_cloudconfig
configdefinitions
+ vespalib
)
diff --git a/logforwarder/src/apps/vespa-logforwarder-start/main.cpp b/logforwarder/src/apps/vespa-logforwarder-start/main.cpp
index e06d3dd6d8d..8fc74fcac8e 100644
--- a/logforwarder/src/apps/vespa-logforwarder-start/main.cpp
+++ b/logforwarder/src/apps/vespa-logforwarder-start/main.cpp
@@ -7,14 +7,14 @@
LOG_SETUP("vespa-logforwarder-start");
#include "cf-handler.h"
-#include "sig-catch.h"
+#include <vespa/vespalib/util/sig_catch.h>
class Wrapper {
const char *_configId;
public:
Wrapper(const char *cfid) : _configId(cfid) {}
void run() {
- SigCatch catcher;
+ vespalib::SigCatch catcher;
CfHandler handler;
handler.start(_configId);
while (! catcher.receivedStopSignal()) {
diff --git a/logforwarder/src/apps/vespa-logforwarder-start/sig-catch.cpp b/logforwarder/src/apps/vespa-logforwarder-start/sig-catch.cpp
deleted file mode 100644
index b10275d515e..00000000000
--- a/logforwarder/src/apps/vespa-logforwarder-start/sig-catch.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#include "sig-catch.h"
-#include <csignal>
-#include <unistd.h>
-#include <string.h>
-
-static int sigPermanent(int sig, void(*handler)(int));
-static void setStopFlag(int sig);
-sig_atomic_t stop = 0;
-
-SigCatch::SigCatch()
-{
- sigPermanent(SIGPIPE, SIG_IGN);
- sigPermanent(SIGTERM, setStopFlag);
- sigPermanent(SIGINT, setStopFlag);
-}
-
-bool
-SigCatch::receivedStopSignal() {
- return stop != 0;
-}
-
-static void
-setStopFlag(int sig)
-{
- (void)sig;
- stop = 1;
-}
-
-static int
-sigPermanent(int sig, void(*handler)(int))
-{
- struct sigaction sa;
-
- memset(&sa, 0, sizeof(sa));
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0; // no SA_RESTART!
- sa.sa_handler = handler;
- return sigaction(sig, &sa, nullptr);
-}
diff --git a/logforwarder/src/apps/vespa-logforwarder-start/sig-catch.h b/logforwarder/src/apps/vespa-logforwarder-start/sig-catch.h
deleted file mode 100644
index 905f37103ec..00000000000
--- a/logforwarder/src/apps/vespa-logforwarder-start/sig-catch.h
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-class SigCatch
-{
-public:
- SigCatch();
- bool receivedStopSignal();
-};