在下面代码中,在SIGINT信号处理过程中,屏蔽SIGQUIT信号的发生,信号SIGQUIT直到SIGINT的信号处理函数完毕后才能被处理
#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <string.h>#include <signal.h>void sig_handle(int signo){ int i = 5; PRintf("catch signal %d/n", (int)signo); while(i--) { printf("wait another signal/n"); sleep(1); }}int main(int argc, char *argv[]){ struct sigaction newact, oldact; newact.sa_handler = sig_handle; sigemptyset(&newact.sa_mask); sigaddset(&newact.sa_mask, SIGQUIT); newact.sa_flags = 0; sigaction(SIGINT, &newact, &oldact); while(1) { printf("main process/n"); sleep(1); } return 0;}
新闻热点
疑难解答