From 42557513bc4740b65175b6ca46307ce023c2a628 Mon Sep 17 00:00:00 2001 From: mrfoxygmfr Date: Wed, 21 May 2025 14:04:19 +0300 Subject: feat(lib): add function to configure timeout --- lib/common.c | 14 ++++++++++++++ lib/common.h | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 lib/common.c diff --git a/lib/common.c b/lib/common.c new file mode 100644 index 0000000..6a54108 --- /dev/null +++ b/lib/common.c @@ -0,0 +1,14 @@ +#include "./common.h" +#include + +void timer_handler(int signum) { + signum = signum; + + printf("Stopping due to timeout\n"); + exit(EXIT_FAILURE); +} + +void configure_timeout(int delay) { + signal(SIGALRM, timer_handler); + alarm(delay); +} diff --git a/lib/common.h b/lib/common.h index ab6c05d..cf566f0 100644 --- a/lib/common.h +++ b/lib/common.h @@ -16,4 +16,6 @@ enum { REQUEST_TYPE_PUT_RESULT, }; +void configure_timeout(int delay); + #endif // COMMON_H -- cgit mrf-deployment