1 16107e2e 2024-06-16 benni #include <unistd.h>
2 16107e2e 2024-06-16 benni #include <signal.h>
3 16107e2e 2024-06-16 benni #include <string.h>
4 16107e2e 2024-06-16 benni #include <stdio.h>
6 16107e2e 2024-06-16 benni void handle_signal (int sig)
8 16107e2e 2024-06-16 benni printf ("Signal: %d\n", sig);
11 16107e2e 2024-06-16 benni int main (void)
13 16107e2e 2024-06-16 benni struct sigaction act;
15 16107e2e 2024-06-16 benni memset (&act, 0, sizeof (act));
16 16107e2e 2024-06-16 benni act.sa_handler = handle_signal;
17 16107e2e 2024-06-16 benni sigaction (SIGINT, &act, NULL);
19 16107e2e 2024-06-16 benni for (int i = 0; i < 3; ++i) {
20 16107e2e 2024-06-16 benni puts ("sleeping...");