Line data Source code
1 : /* This file is part of the cmail project (http://cmail.rocks/)
2 : * (c) 2015 Fabian "cbdev" Stumpf
3 : * License: Simplified BSD (2-Clause)
4 : * For further information, consult LICENSE.txt
5 : */
6 :
7 1 : void signal_handle(int signum){
8 1 : abort_signaled = 1;
9 1 : }
10 :
11 1 : int signal_init(LOGGER log){
12 1 : struct sigaction act = {
13 : .sa_handler=&signal_handle
14 : };
15 :
16 : //FIXME use sigaction for this too
17 1 : signal(SIGPIPE, SIG_IGN);
18 :
19 1 : if(sigaction(SIGTERM, &act, NULL) < 0 || sigaction(SIGINT, &act, NULL) < 0) {
20 0 : logprintf(log, LOG_ERROR, "Failed to set signal mask\n");
21 0 : return -1;
22 : }
23 :
24 1 : return 0;
25 : }
|