e6a4326e21318cca4e05b1eb979d2864962ee9fa
[platform/upstream/mtools.git] / signal.c
1 /*  Copyright 1996,1997,2001,2002,2007,2009 Alain Knaff.
2  *  This file is part of mtools.
3  *
4  *  Mtools is free software: you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation, either version 3 of the License, or
7  *  (at your option) any later version.
8  *
9  *  Mtools is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with Mtools.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include "sysincludes.h"
19 #include "mtools.h"
20
21 #undef got_signal
22
23 int got_signal = 0;
24
25 static void signal_handler(int dummy)
26 {
27         got_signal = 1;
28 #if 0
29         signal(SIGHUP, SIG_IGN);
30         signal(SIGINT, SIG_IGN);
31         signal(SIGTERM, SIG_IGN);
32         signal(SIGQUIT, SIG_IGN);
33 #endif
34 }
35
36 #if 0
37 int do_gotsignal(char *f, int n)
38 {
39         if(got_signal)
40                 fprintf(stderr, "file=%s line=%d\n", f, n);
41         return got_signal;
42 }
43 #endif
44
45 void setup_signal(void)
46 {
47         /* catch signals */
48 #ifdef SIGHUP
49         signal(SIGHUP, signal_handler);
50 #endif
51 #ifdef SIGINT
52         signal(SIGINT, signal_handler);
53 #endif
54 #ifdef SIGTERM
55         signal(SIGTERM, signal_handler);
56 #endif
57 #ifdef SIGQUIT
58         signal(SIGQUIT, signal_handler);
59 #endif
60 }