📄 p8-4.c
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -