]> git.proxmox.com Git - mirror_frr.git/blob - tests/lib/test_sig.c
*: reindent
[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
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
20 #include <zebra.h>
21 #include <sigevent.h>
22 #include "lib/log.h"
23 #include "lib/memory.h"
24
25 static void sighup(void)
26 {
27 printf("processed hup\n");
28 }
29
30 static void sigusr1(void)
31 {
32 printf("processed usr1\n");
33 }
34
35 static void sigusr2(void)
36 {
37 printf("processed usr2\n");
38 }
39
40 struct quagga_signal_t sigs[] = {{
41 .signal = SIGHUP,
42 .handler = &sighup,
43 },
44 {
45 .signal = SIGUSR1,
46 .handler = &sigusr1,
47 },
48 {
49 .signal = SIGUSR2,
50 .handler = &sigusr2,
51 }};
52
53 struct thread_master *master;
54 struct thread t;
55
56 int main(void)
57 {
58 master = thread_master_create();
59 signal_init(master, array_size(sigs), sigs);
60
61 openzlog("testsig", "NONE", 0, LOG_CONS | LOG_NDELAY | LOG_PID,
62 LOG_DAEMON);
63 zlog_set_level(ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
64 zlog_set_level(ZLOG_DEST_STDOUT, LOG_DEBUG);
65 zlog_set_level(ZLOG_DEST_MONITOR, ZLOG_DISABLED);
66
67 while (thread_fetch(master, &t))
68 thread_call(&t);
69
70 exit(0);
71 }