Fix: syscall event rule: emission sites not compared in is_equal
[lttng-tools.git] / tests / utils / testapp / signal-helper.hpp
CommitLineData
95983a02 1/*
9d16b343 2 * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
95983a02 3 *
9d16b343 4 * SPDX-License-Identifier: LGPL-2.1-only
95983a02 5 *
95983a02
JG
6 */
7
8#ifndef LTTNG_TESTAPP_SIGNAL_HELPER_H
9#define LTTNG_TESTAPP_SIGNAL_HELPER_H
10
11#include <signal.h>
52e345b9 12#include <stdio.h>
95983a02
JG
13
14static volatile int should_quit;
15
28f23191 16static void sighandler(int sig)
95983a02
JG
17{
18 if (sig == SIGTERM) {
19 should_quit = 1;
20 }
21}
22
28f23191 23static int set_signal_handler()
95983a02
JG
24{
25 int ret;
729c1fec
SM
26 struct sigaction sa {};
27 sa.sa_flags = 0;
28 sa.sa_handler = sighandler;
95983a02
JG
29
30 ret = sigemptyset(&sa.sa_mask);
31 if (ret) {
32 perror("sigemptyset");
33 goto end;
34 }
35
cd9adb8b 36 ret = sigaction(SIGTERM, &sa, nullptr);
95983a02
JG
37 if (ret) {
38 perror("sigaction");
39 goto end;
40 }
41end:
42 return ret;
43}
44
45#endif /* LTTNG_TESTAPP_SIGNAL_HELPER_H */
This page took 0.051519 seconds and 5 git commands to generate.