23 lines
413 B
C
23 lines
413 B
C
#include <signal.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
|
|
void handler(int sig) {
|
|
write(1, "Caught SIGINT\n", 14); // Async-signal-safe output
|
|
exit(1);
|
|
}
|
|
|
|
int main() {
|
|
struct sigaction sa;
|
|
sa.sa_handler = handler;
|
|
sigemptyset(&sa.sa_mask);
|
|
sa.sa_flags = 0;
|
|
|
|
sigaction(SIGINT, &sa, NULL);
|
|
|
|
while (1) {
|
|
printf("Running...\n");
|
|
sleep(1);
|
|
}
|
|
}
|