signal()
<signal.h>中 signal()函数的声明:
/* Type of a signal handler. */ typedef void (*__sighandler_t) (int); extern __sighandler_t signal (int __sig, __sighandler_t __handler) __THROW;
static void handle_term( int sig ) { printf("%d\n",sig); exit(0); } int main( int argc, char* argv[] ) { signal( SIGTERM, handle_term ); //当进程收到 SIGTERM 信号时,handle_term 函数会被调用。参数sig等于SIGTERM
}