diff --git a/examples/custom_logger.c b/examples/custom_logger.c index 0221f30..f5f85ef 100644 --- a/examples/custom_logger.c +++ b/examples/custom_logger.c @@ -8,13 +8,12 @@ #include #include -static bool running = true; +static sig_atomic_t stop = 0; static void sigint_handler(int signum) { - (void)signum; - running = false; + stop = signum; } static th_err @@ -64,7 +63,7 @@ int main(int argc, char** argv) goto cleanup; if ((err = th_route(server, TH_METHOD_GET, "/", handler, NULL)) != TH_ERR_OK) goto cleanup; - while (running) { + while (!stop) { th_poll(server, 1000); } fprintf(stderr, "Shutting down...\n"); diff --git a/examples/echo.c b/examples/echo.c index 7dfe807..e28171a 100644 --- a/examples/echo.c +++ b/examples/echo.c @@ -5,12 +5,12 @@ #include #include -static bool running = true; +static sig_atomic_t stop = 0; -static void sigint_handler(int signum) +static void +sigint_handler(int signum) { - (void)signum; - running = false; + stop = signum; } const char* method_strings[] = { @@ -68,7 +68,7 @@ int main(int argc, char** argv) goto cleanup; if ((err = th_route(server, TH_METHOD_ANY, "/{path:path}", handler, NULL)) != TH_ERR_OK) goto cleanup; - while (running) { + while (!stop) { th_poll(server, 1000); } fprintf(stderr, "Shutting down...\n"); diff --git a/examples/file_server.c b/examples/file_server.c index 3b401e0..601ed33 100644 --- a/examples/file_server.c +++ b/examples/file_server.c @@ -5,13 +5,12 @@ #include #include -static bool running = true; +static sig_atomic_t stop = 0; static void sigint_handler(int signum) { - (void)signum; - running = false; + stop = signum; } static th_err @@ -89,7 +88,7 @@ int main(int argc, char** argv) goto cleanup; if ((err = th_route(server, TH_METHOD_GET, "/", handle_index, NULL)) != TH_ERR_OK) goto cleanup; - while (running) { + while (!stop) { th_poll(server, 1000); } fprintf(stderr, "Shutting down...\n"); diff --git a/examples/hello_world.c b/examples/hello_world.c index 76b3f8b..a6ffeda 100644 --- a/examples/hello_world.c +++ b/examples/hello_world.c @@ -5,13 +5,12 @@ #include #include -static bool running = true; +static sig_atomic_t stop = 0; static void sigint_handler(int signum) { - (void)signum; - running = false; + stop = signum; } static th_err @@ -37,7 +36,7 @@ int main(int argc, char** argv) goto cleanup; if ((err = th_route(server, TH_METHOD_GET, "/", handler, NULL)) != TH_ERR_OK) goto cleanup; - while (running) { + while (!stop) { th_poll(server, 1000); } fprintf(stderr, "Shutting down...\n");