import v0.1
[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
9 void (*crtlc_cb)(void) = 0;
10
11 void handlerINT(int s)
12 {
13         log_printf("caught sig int ... cleaning up\n");
14         if(crtlc_cb)
15                 crtlc_cb();
16         exit(0);
17 }
18
19 void signal_init(void (*_crtlc_cb)(void))
20 {
21         struct sigaction s;
22         crtlc_cb = _crtlc_cb;
23         s.sa_handler = handlerINT;
24         s.sa_flags = 0;
25         sigaction(SIGINT, &s, NULL);
26 }