摘自《专业嵌入式软件开发 全面走向高质高效编程 电子工业出版社 李云》
#define CONFIG_MAX_INTERRUPT 64
typedef void (*interrupt_handler_t)(int _vector)static interrupt_handler_t g_interruput_vector[CONFIG_MAX_INTERRUPT];
static void signal_handler (int _signal)
{
g_interruput_vector[_signal](_signal);
}
static void sinal_init()
{
struct sigaction action;
sigset_t mask;
mask = g_sigprocmask (SIG_UNBLOCK, &mask, 0);
action.sa_handler = signal_handler;
action.sa_mask = mask;
action.sa_flags = SA_RESTART;
(void) siagaction(SIGINT, &action, 0);
(void) siagaction(SIGQUIT, &action, 0);
(void) siagaction(SIGKILL, &action, 0);
(void) siagaction(SIGALARM, &action, 0);
(void) siagaction(SIGSTOP, &action, 0);
}