Paul Jakma | 010ebbb | 2014-09-16 11:53:49 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * This file is part of Quagga. |
| 3 | * |
| 4 | * Quagga is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License as published by the |
| 6 | * Free Software Foundation; either version 2, or (at your option) any |
| 7 | * later version. |
| 8 | * |
| 9 | * Quagga is distributed in the hope that it will be useful, but |
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with Quagga; see the file COPYING. If not, write to the Free |
| 16 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 17 | * 02111-1307, USA. |
| 18 | */ |
| 19 | |
paul | 9a76e2d | 2004-01-19 21:25:17 +0000 | [diff] [blame] | 20 | #include <zebra.h> |
| 21 | #include <sigevent.h> |
Paul Jakma | 1602a71 | 2006-05-28 08:32:44 +0000 | [diff] [blame] | 22 | #include "lib/log.h" |
David Lamparter | 326fe3d | 2012-11-03 09:13:23 -0700 | [diff] [blame] | 23 | #include "lib/memory.h" |
paul | 9a76e2d | 2004-01-19 21:25:17 +0000 | [diff] [blame] | 24 | |
| 25 | void |
| 26 | sighup (void) |
| 27 | { |
| 28 | printf ("processed hup\n"); |
| 29 | } |
| 30 | |
| 31 | void |
| 32 | sigusr1 (void) |
| 33 | { |
| 34 | printf ("processed usr1\n"); |
| 35 | } |
| 36 | |
| 37 | void |
| 38 | sigusr2 (void) |
| 39 | { |
| 40 | printf ("processed usr2\n"); |
| 41 | } |
| 42 | |
| 43 | struct quagga_signal_t sigs[] = |
| 44 | { |
| 45 | { |
| 46 | .signal = SIGHUP, |
| 47 | .handler = &sighup, |
| 48 | }, |
| 49 | { |
| 50 | .signal = SIGUSR1, |
| 51 | .handler = &sigusr1, |
| 52 | }, |
| 53 | { |
| 54 | .signal = SIGUSR2, |
| 55 | .handler = &sigusr2, |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | struct thread_master *master; |
| 60 | struct thread t; |
| 61 | |
| 62 | int |
| 63 | main (void) |
| 64 | { |
| 65 | master = thread_master_create (); |
Balaji.G | 837d16c | 2012-09-26 14:09:10 +0530 | [diff] [blame] | 66 | signal_init (master, array_size(sigs), sigs); |
Paul Jakma | f783c1d | 2006-05-28 08:31:17 +0000 | [diff] [blame] | 67 | |
| 68 | zlog_default = openzlog("testsig", ZLOG_NONE, |
| 69 | LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); |
| 70 | zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED); |
| 71 | zlog_set_level (NULL, ZLOG_DEST_STDOUT, LOG_DEBUG); |
| 72 | zlog_set_level (NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED); |
| 73 | |
paul | 9a76e2d | 2004-01-19 21:25:17 +0000 | [diff] [blame] | 74 | while (thread_fetch (master, &t)) |
| 75 | thread_call (&t); |
| 76 | |
| 77 | exit (0); |
| 78 | } |