aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/src/signal.c
blob: ca754558cae99aaa6a7ad66195545f181b44018a (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) {
		log_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);
}