summaryrefslogtreecommitdiffstats
path: root/lib/common.c
diff options
context:
space:
mode:
authormrfoxygmfr <mrfoxygmfr@sch9.ru>2025-05-21 14:04:19 +0300
committermrfoxygmfr <mrfoxygmfr@sch9.ru>2025-05-21 14:04:19 +0300
commit42557513bc4740b65175b6ca46307ce023c2a628 (patch)
treedac40219c71b3078f67658eeb8a1d1aaf4e297ce /lib/common.c
parent7d4e357bac40a3ef792bb9fc25c9340c5b0131d6 (diff)
feat(lib): add function to configure timeout
Diffstat (limited to 'lib/common.c')
-rw-r--r--lib/common.c14
1 files changed, 14 insertions, 0 deletions
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 <signal.h>
+
+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);
+}