summaryrefslogtreecommitdiffstats
path: root/tests/lib/test_sig.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 13:16:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 13:16:35 +0000
commite2bbf175a2184bd76f6c54ccf8456babeb1a46fc (patch)
treef0b76550d6e6f500ada964a3a4ee933a45e5a6f1 /tests/lib/test_sig.c
parentInitial commit. (diff)
downloadfrr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.tar.xz
frr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.zip
Adding upstream version 9.1.upstream/9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/lib/test_sig.c')
-rw-r--r--tests/lib/test_sig.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/lib/test_sig.c b/tests/lib/test_sig.c
new file mode 100644
index 0000000..2bd7f30
--- /dev/null
+++ b/tests/lib/test_sig.c
@@ -0,0 +1,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);
+}