]> mj.ucw.cz Git - libucw.git/blob - lib/sighandler.c
9a76851423eaeaa5ad94c72e30ce1fab2988ee07
[libucw.git] / lib / sighandler.c
1 /*
2  *      UCW Library -- Catching of signals and calling callback functions
3  *
4  *      (c) 2004, Robert Spalek <robert@ucw.cz>
5  */
6
7 #include "lib/lib.h"
8
9 #include <stdlib.h>
10 #include <string.h>
11 #include <signal.h>
12
13 sh_sighandler_t signal_handler[_NSIG];
14
15 static void
16 signal_handler_internal(int sig)
17 {
18   if (signal_handler[sig])
19   {
20     if (!signal_handler[sig](sig))
21       return;
22   }
23   abort();
24 }
25
26 void
27 handle_signal(int signum, struct sigaction *oldact)
28 {
29 #if 0
30   struct sigaction act;
31   bzero(&act, sizeof(act));
32   act.sa_handler = signal_handler_internal;
33   act.sa_flags = SA_NOMASK;
34   if (sigaction(signum, &act, oldact) < 0)
35     die("sigaction: %m");
36 #endif
37 }
38
39 void
40 unhandle_signal(int signum, struct sigaction *oldact)
41 {
42 #if 0
43   if (sigaction(signum, oldact, NULL) < 0)
44     die("sigaction: %m");
45 #endif
46 }