#include <iostream>
#include <unistd.h>
#include <signal.h>
using namespace std;
void handler (int signum)
{
cout << "获取了一个信号:" << signum << endl;
sleep(10);
}
int main()
{
struct sigaction act, oact;
act.sa_flags = 0;
sigemptyset (&act.sa_mask);
act.sa_handler = handler;
sigaction(2,&act,&oact);
cout << "default action : " << (int)oact.sa_handler << endl;
while(true) sleep(1);
return 0;
}
Linux--当某个信号的处理函数被调用时,内核自动将当前信号加入进程的信号屏蔽字
最新推荐文章于 2024-11-07 10:17:21 发布