标签:
#include <stdlib.h> #include <stdio.h> #include <errno.h> #include <string.h> #include <iostream> #include <unistd.h> #include <signal.h> using namespace std; typedef void (*sighandler_t)(int); void handler( int sig ) { cout << "sig = " << sig << endl; } int main(int argc, char *argv[]) { sighandler_t oldHandler = signal(SIGINT, handler); if ( oldHandler == SIG_ERR ) exit(1); sleep(1); if ( signal(SIGINT, oldHandler) == SIG_ERR ) exit(1); sleep(10); return 0; }
标签:
原文地址:http://www.cnblogs.com/kaishan1990/p/5573129.html