Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 1 | /* |
| 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 | |
David Lamparter | 821df2c | 2015-09-15 01:53:09 -0700 | [diff] [blame] | 23 | #include <zebra.h> |
| 24 | |
Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 25 | #include <signal.h> |
| 26 | |
Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 27 | #include "sigevent.h" |
Everton Marques | ff57d36 | 2014-06-25 15:54:03 -0300 | [diff] [blame] | 28 | #include "memory.h" |
Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 29 | #include "log.h" |
| 30 | |
| 31 | #include "pim_signals.h" |
| 32 | #include "pimd.h" |
| 33 | |
| 34 | /* |
| 35 | * Signal handlers |
| 36 | */ |
| 37 | |
| 38 | static void pim_sighup() |
| 39 | { |
| 40 | zlog_debug ("SIGHUP received, ignoring"); |
| 41 | } |
| 42 | |
| 43 | static void pim_sigint() |
| 44 | { |
| 45 | zlog_notice("Terminating on signal SIGINT"); |
| 46 | pim_terminate(); |
| 47 | exit(1); |
| 48 | } |
| 49 | |
| 50 | static void pim_sigterm() |
| 51 | { |
| 52 | zlog_notice("Terminating on signal SIGTERM"); |
| 53 | pim_terminate(); |
| 54 | exit(1); |
| 55 | } |
| 56 | |
| 57 | static void pim_sigusr1() |
| 58 | { |
| 59 | zlog_debug ("SIGUSR1 received"); |
| 60 | zlog_rotate (NULL); |
| 61 | } |
| 62 | |
Everton Marques | ff57d36 | 2014-06-25 15:54:03 -0300 | [diff] [blame] | 63 | static struct quagga_signal_t pimd_signals[] = |
Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 64 | { |
| 65 | { |
| 66 | .signal = SIGHUP, |
| 67 | .handler = &pim_sighup, |
| 68 | }, |
| 69 | { |
| 70 | .signal = SIGUSR1, |
| 71 | .handler = &pim_sigusr1, |
| 72 | }, |
| 73 | { |
| 74 | .signal = SIGINT, |
| 75 | .handler = &pim_sigint, |
| 76 | }, |
| 77 | { |
| 78 | .signal = SIGTERM, |
| 79 | .handler = &pim_sigterm, |
| 80 | }, |
| 81 | }; |
| 82 | |
| 83 | void pim_signals_init() |
| 84 | { |
Everton Marques | ff57d36 | 2014-06-25 15:54:03 -0300 | [diff] [blame] | 85 | signal_init(master, array_size(pimd_signals), pimd_signals); |
Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 86 | } |
| 87 | |