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