blob: f24da965c327d39aa2ce235ff0bef8343352602a [file] [log] [blame]
Paul Jakma010ebbb2014-09-16 11:53:49 +01001/*
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
paul9a76e2d2004-01-19 21:25:17 +000020#include <zebra.h>
21#include <sigevent.h>
Paul Jakma1602a712006-05-28 08:32:44 +000022#include "lib/log.h"
David Lamparter326fe3d2012-11-03 09:13:23 -070023#include "lib/memory.h"
paul9a76e2d2004-01-19 21:25:17 +000024
David Lamparterc3138952015-04-21 10:02:23 +020025static void
paul9a76e2d2004-01-19 21:25:17 +000026sighup (void)
27{
28 printf ("processed hup\n");
29}
30
David Lamparterc3138952015-04-21 10:02:23 +020031static void
paul9a76e2d2004-01-19 21:25:17 +000032sigusr1 (void)
33{
34 printf ("processed usr1\n");
35}
36
David Lamparterc3138952015-04-21 10:02:23 +020037static void
paul9a76e2d2004-01-19 21:25:17 +000038sigusr2 (void)
39{
40 printf ("processed usr2\n");
41}
42
43struct 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
59struct thread_master *master;
60struct thread t;
61
62int
63main (void)
64{
65 master = thread_master_create ();
Balaji.G837d16c2012-09-26 14:09:10 +053066 signal_init (master, array_size(sigs), sigs);
Paul Jakmaf783c1d2006-05-28 08:31:17 +000067
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
paul9a76e2d2004-01-19 21:25:17 +000074 while (thread_fetch (master, &t))
75 thread_call (&t);
76
77 exit (0);
78}