]> git.proxmox.com Git - mirror_frr.git/blob - tests/lib/test_sig.c
lib: more `show thread cpu`
[mirror_frr.git] / tests / lib / test_sig.c
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 along
15 * with this program; see the file COPYING; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <zebra.h>
20 #include <sigevent.h>
21 #include "lib/log.h"
22 #include "lib/memory.h"
23
24 static void
25 sighup (void)
26 {
27 printf ("processed hup\n");
28 }
29
30 static void
31 sigusr1 (void)
32 {
33 printf ("processed usr1\n");
34 }
35
36 static void
37 sigusr2 (void)
38 {
39 printf ("processed usr2\n");
40 }
41
42 struct quagga_signal_t sigs[] =
43 {
44 {
45 .signal = SIGHUP,
46 .handler = &sighup,
47 },
48 {
49 .signal = SIGUSR1,
50 .handler = &sigusr1,
51 },
52 {
53 .signal = SIGUSR2,
54 .handler = &sigusr2,
55 }
56 };
57
58 struct thread_master *master;
59 struct thread t;
60
61 int
62 main (void)
63 {
64 master = thread_master_create(NULL);
65 signal_init (master, array_size(sigs), sigs);
66
67 openzlog("testsig", "NONE", 0, LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON);
68 zlog_set_level(ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
69 zlog_set_level(ZLOG_DEST_STDOUT, LOG_DEBUG);
70 zlog_set_level(ZLOG_DEST_MONITOR, ZLOG_DISABLED);
71
72 while (thread_fetch (master, &t))
73 thread_call (&t);
74
75 exit (0);
76 }