blob: d1350b08b3e6c6227329e20cd975d1447bc920e9 [file] [log] [blame]
Everton Marques871dbcf2009-08-11 15:43:05 -03001/*
2 PIM for Quagga
3 Copyright (C) 2008 Everton da Silva Marques
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING; if not, write to the
17 Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
18 MA 02110-1301 USA
19
20 $QuaggaId: $Format:%an, %ai, %h$ $
21*/
22
23#include <signal.h>
24
25#include <zebra.h>
26#include "sigevent.h"
Everton Marquesff57d362014-06-25 15:54:03 -030027#include "memory.h"
Everton Marques871dbcf2009-08-11 15:43:05 -030028#include "log.h"
29
30#include "pim_signals.h"
31#include "pimd.h"
32
33/*
34 * Signal handlers
35 */
36
37static void pim_sighup()
38{
39 zlog_debug ("SIGHUP received, ignoring");
40}
41
42static void pim_sigint()
43{
44 zlog_notice("Terminating on signal SIGINT");
45 pim_terminate();
46 exit(1);
47}
48
49static void pim_sigterm()
50{
51 zlog_notice("Terminating on signal SIGTERM");
52 pim_terminate();
53 exit(1);
54}
55
56static void pim_sigusr1()
57{
58 zlog_debug ("SIGUSR1 received");
59 zlog_rotate (NULL);
60}
61
Everton Marquesff57d362014-06-25 15:54:03 -030062static struct quagga_signal_t pimd_signals[] =
Everton Marques871dbcf2009-08-11 15:43:05 -030063{
64 {
65 .signal = SIGHUP,
66 .handler = &pim_sighup,
67 },
68 {
69 .signal = SIGUSR1,
70 .handler = &pim_sigusr1,
71 },
72 {
73 .signal = SIGINT,
74 .handler = &pim_sigint,
75 },
76 {
77 .signal = SIGTERM,
78 .handler = &pim_sigterm,
79 },
80};
81
82void pim_signals_init()
83{
Everton Marquesff57d362014-06-25 15:54:03 -030084 signal_init(master, array_size(pimd_signals), pimd_signals);
Everton Marques871dbcf2009-08-11 15:43:05 -030085}
86