标签:
#include <signal.h>
int sigaction(int signo, const struct sigaction *act, struct sigaction *oact);
struct sigaction {
void (*sa_handler)(int);
void (*sa_sigaction)(int, siginfo_t *, void *);
sigset_t sa_mask;
int sa_flags;
void (*sa_restorer)(void);
}
void catch_Signal(int Sign) { switch (Sign) { case SIGINT: printf("SIGINT Signal\n"); exit(0); } } int signal1(int signo, void (*func)(int)) { struct sigaction act, oact; act.sa_handler = func; sigemptyset(&act.sa_mask); act.sa_flags = 0; return sigaction(signo, &act, &oact); } int main(int arg, char *args[]) { signal1(SIGINT, catch_Signal); pause(); return 0; }
标签:
原文地址:http://www.cnblogs.com/shichuan/p/4496340.html