?? ctrlc1.c
字號:
/* We'll start by writing the function which reacts to the signal which is passed in the parameter sig. This is the function we will arrange to be called when a signal occurs. We print a message, then reset the signal handling for SIGINT (by default generated by pressing CTRL-C) back to the default behavior. Let's call this function ouch. */#include <signal.h>#include <stdio.h>#include <unistd.h>void ouch(int sig){ printf("OUCH! - I got signal %d\n", sig); (void) signal(SIGINT, SIG_DFL);}/* The main function has to intercept the SIGINT signal generated when we type Ctrl-C . For the rest of the time, it just sits in an infinite loop, printing a message once a second. */int main(){ (void) signal(SIGINT, ouch); while(1) { printf("Hello World!\n"); sleep(1); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -