fix(main): fix SIGINT exit

This commit is contained in:
iridiumR 2022-09-18 11:44:39 +08:00
parent 88cabfb434
commit c2b3c98e31
No known key found for this signature in database
GPG key ID: 5574BE4450D55618

7
main.c
View file

@ -1,12 +1,13 @@
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include "line.h"
static volatile int keepRunning = 1;
void intHandler(int dummy) {
printf("\nend!\n");
keepRunning = 0;
exit(EXIT_FAILURE);
}
int main(int argc, char *argv[]) {
@ -17,7 +18,7 @@ int main(int argc, char *argv[]) {
#ifdef DEBUG
printf("DEBUG is defined\n");
#endif
while (keepRunning) {
while (1) {
printf("runing!\n");
sleep(1);
}