Signals exampe, sigaction included

This commit is contained in:
Imbus 2025-08-28 14:45:30 +02:00
parent f3522129a3
commit 080928d3fd
3 changed files with 64 additions and 0 deletions

17
signals/main.c Normal file
View file

@ -0,0 +1,17 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void handler(int sig) {
printf("Caught signal %d\n", sig);
exit(1);
}
int main() {
signal(SIGINT, handler); // Handle Ctrl+C
while (1) {
printf("Running...\n");
sleep(1);
}
}