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