blob: cc0cef682e0843bd024592e3630a58d80eb911d4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "signalshutdown.h"
#include "transport.h"
#include <vespa/vespalib/util/signalhandler.h>
FNET_SignalShutDown::FNET_SignalShutDown(FNET_Transport &t)
: FNET_Task(t.GetScheduler()),
_transport(t)
{
ScheduleNow();
}
void
FNET_SignalShutDown::PerformTask()
{
using SIG = vespalib::SignalHandler;
if (SIG::INT.check() || SIG::TERM.check()) {
fprintf(stderr, "got signal, shutting down...\n");
_transport.ShutDown(false);
} else {
Schedule(0.1);
}
}
void
FNET_SignalShutDown::hookSignals()
{
using SIG = vespalib::SignalHandler;
SIG::INT.hook();
SIG::TERM.hook();
}
|