File: test_sig.c

package info (click to toggle)
frr 10.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 77,224 kB
  • sloc: ansic: 687,301; python: 227,378; perl: 6,379; sh: 2,685; cpp: 1,883; makefile: 670; yacc: 397; lex: 363; lisp: 66; xml: 35; javascript: 8
file content (52 lines) | stat: -rw-r--r-- 835 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 */

#include <zebra.h>
#include <sigevent.h>
#include "lib/log.h"
#include "lib/memory.h"

static void sighup(void)
{
	printf("processed hup\n");
}

static void sigusr1(void)
{
	printf("processed usr1\n");
}

static void sigusr2(void)
{
	printf("processed usr2\n");
}

struct frr_signal_t sigs[] = {{
				      .signal = SIGHUP,
				      .handler = &sighup,
			      },
			      {
				      .signal = SIGUSR1,
				      .handler = &sigusr1,
			      },
			      {
				      .signal = SIGUSR2,
				      .handler = &sigusr2,
			      }};

struct event_loop *master;
struct event t;

int main(void)
{
	master = event_master_create(NULL);
	signal_init(master, array_size(sigs), sigs);

	zlog_aux_init("NONE: ", LOG_DEBUG);

	while (event_fetch(master, &t))
		event_call(&t);

	exit(0);
}