feat(main): add SIGINT detect
This commit is contained in:
parent
69229a3285
commit
88cabfb434
1 changed files with 21 additions and 6 deletions
21
main.c
21
main.c
|
@ -1,10 +1,25 @@
|
|||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static volatile int keepRunning = 1;
|
||||
|
||||
void intHandler(int dummy) {
|
||||
printf("\nend!\n");
|
||||
keepRunning = 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
printf("Hello, World!");
|
||||
|
||||
signal(SIGINT, intHandler);
|
||||
|
||||
printf("Hello, World!\n");
|
||||
#ifdef DEBUG
|
||||
printf("DEBUG is defined");
|
||||
printf("DEBUG is defined\n");
|
||||
#endif
|
||||
while (keepRunning) {
|
||||
printf("runing!\n");
|
||||
sleep(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue