linux中信号的程序实例

#include<signal.h>
#include<stdio.h>
#include<stdlib.h>

void func(int sig){
        printf("the function of ctrl+c is instead\n");
}

int main(){

        signal(SIGINT,func);
        while(1){
        printf(".\n");
        sleep(1);
        }

        return 0;

}
~                                                                               
~    

编辑执行这个文件后,按下CTRL+C 时原本的中断命令被换成 the function of ctrl+c is instead

猜你喜欢

转载自blog.csdn.net/cxyzyywoaini/article/details/87465718
今日推荐