p8-4.c
来自「SUN Solaris8平台下进程间通信」· C语言 代码 · 共 28 行
C
28 行
#include <signal.h>void termination_handler(int signum){ struct temp_file *p; for (p = temp_file_list; p; p = p->next) unlink (p->name);}int main (void){ ... struct sigaction new_action, old_action; /* 设置sigaction结构指明信号动作. */ new_action.sa_handler = termination_handler; sigemptyset(&new_action.sa_mask); new_action.sa_flags = 0; /* 分别查询各个信号的当前设置,仅当它们不是SIG_IGN时才设置新的句柄 */ sigaction(SIGINT, NULL, &old_action); if (old_action.sa_handler != SIG_IGN) sigaction (SIGINT, &new_action, NULL); sigaction(SIGHUP, NULL, &old_action); if (old_action.sa_handler != SIG_IGN) sigaction (SIGHUP, &new_action, NULL); sigaction(SIGTERM, NULL, &old_action); if (old_action.sa_handler != SIG_IGN) sigaction (SIGTERM, &new_action, NULL); ...}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?