4a4450c91c88dbe189ef2d667efe4767abd67d99
[oweals/mountd.git] / signal.c
1 #include <signal.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4
5 #include "include/log.h"
6 #include "include/list.h"
7 #include "include/led.h"
8 #include "include/signal.h"
9
10 void (*crtlc_cb)(void) = 0;
11
12 static void handlerINT(int s)
13 {
14         log_printf("caught sig int ... cleaning up\n");
15         if(crtlc_cb)
16                 crtlc_cb();
17         exit(0);
18 }
19
20 void signal_init(void (*_crtlc_cb)(void))
21 {
22         struct sigaction s;
23         crtlc_cb = _crtlc_cb;
24         s.sa_handler = handlerINT;
25         s.sa_flags = 0;
26         sigaction(SIGINT, &s, NULL);
27 }