summaryrefslogtreecommitdiff
path: root/src/server/signal.cc
blob: ea7ae3e3d09a95f23aaa1bbc887fccaacb8588b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// SPDX-License-Identifier: BSD-3-Clause

#include "signal.h"

namespace server {

volatile sig_atomic_t shutdownCaught = 0;

static void sighandler(int) {
    shutdownCaught = 1;
}

void set_signal_handlers() {
    struct sigaction sa = {0};
    sa.sa_handler = sighandler;
    sigaction(SIGTERM, &sa, nullptr);
    sigaction(SIGINT, &sa, nullptr);
}

}