aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/src/signal.c
blob: c3ea7c3882b69b996339288230dc62529cb38aec (plain) (tree)
1
2
3
4
5
6
7
8
9


                   



                                           
                                                  
 

                    

















                                                 




                                 
                                      
 
#include "signal.h"
#include "log.h"

#include <signal.h>

volatile sig_atomic_t global_stop_flag = 0;

int signal_set(const sigset_t *new, sigset_t *old)
{
	int ret = 0;

	ret = sigprocmask(SIG_SETMASK, new, old);
	if (ret < 0) {
		print_errno("sigprocmask");
		return ret;
	}

	return ret;
}

int signal_block_parent(sigset_t *old)
{
	sigset_t new;
	sigfillset(&new);
	return signal_set(&new, old);
}

int signal_block_child()
{
	sigset_t set;
	sigemptyset(&set);
	sigaddset(&set, SIGINT);
	sigaddset(&set, SIGQUIT);
	sigaddset(&set, SIGTERM);
	return signal_set(&set, NULL);
}