Update copyright year for 2009.
[inoclam.git] / src / signal.cxx
blob6a230569c914165158d0ff1d9dd2ffe701cf1d2f
1 /*
2 * inoclam - Inotify+ClamAV virus scanner
3 * Copyright (C) 2007, 2008, 2009 Vermont Department of Taxes
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * This program 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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include <libdaemon/dlog.h>
20 #include <signal.h>
22 #include "signal.hxx"
24 /**
25 * Global variable used to determine if the program should halt. Will it ever halt? Only Alan Turing knows.
26 * @see handle_signal()
28 int exit_now;
30 /**
31 * Signal handler for SIGKILL
32 * @param sig signal to handle.
34 void handle_sigkill(int sig)
36 if (sig == SIGKILL) {
37 exit_now = 1;
38 daemon_log(LOG_INFO, "SIGKILL Caught ; preparing to exit");
42 /**
43 * Signal handler for SIGQUIT
44 * @param sig signal to handle.
46 void handle_sigquit(int sig)
48 if (sig == SIGQUIT) {
49 exit_now = 1;
50 daemon_log(LOG_INFO, "SIGQUIT Caught ; preparing to exit");
54 /**
55 * Signal handler for SIGINT
56 * @param sig signal to handle.
58 void handle_sigint(int sig)
60 if (sig == SIGINT) {
61 exit_now = 1;
62 daemon_log(LOG_INFO, "SIGINT Caught ; preparing to exit");
66 /**
67 * installs signal handlers (mostly SIG_IGN)
69 void install_signal_handlers()
72 int i;
74 for (i = 0; i < 32; i++) {
75 if (i != SIGCHLD && i != SIGQUIT && i != SIGINT && i != SIGKILL) {
76 signal(i, SIG_IGN);
80 signal(SIGKILL, handle_sigkill);
81 signal(SIGQUIT, handle_sigquit);
82 signal(SIGINT, handle_sigint);