diff --git a/main.c b/main.c index 71543aa..6197e7f 100644 --- a/main.c +++ b/main.c @@ -16,12 +16,38 @@ * . */ +#include +#include #include +#include + +static bool exit_requested = false; + +void handle_exit_signal(int signum) +{ + (void)signum; + exit_requested = true; +} int main(int argc, char *argv[]) { (void)argc; (void)argv; + if (signal(SIGTERM, handle_exit_signal) == SIG_ERR) { + fprintf(stderr, "Failed to register SIGTERM signal handler\n"); + return 1; + } + if (signal(SIGINT, handle_exit_signal) == SIG_ERR) { + fprintf(stderr, "Failed to register SIGINT signal handler\n"); + return 1; + } + + while (!exit_requested) { + sleep(1); + } + + printf("After loop\n"); + return 0; }