aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/signal.c
blob: a0b9c3da01196d25b56eead174cb483427a87766 (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
#include "signal.h"
#include "log.h"

#include <pthread.h>
#include <signal.h>

volatile sig_atomic_t global_stop_flag = 0;

int signal_set_thread_attr(pthread_attr_t *attr)
{
	int ret = 0;

	sigset_t set;
	sigemptyset(&set);
	sigaddset(&set, SIGINT);
	sigaddset(&set, SIGQUIT);
	sigaddset(&set, SIGTERM);

	ret = pthread_attr_setsigmask_np(attr, &set);
	if (ret) {
		pthread_print_errno(ret, "pthread_attr_setsigmask_np");
		return ret;
	}

	return ret;
}