summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/common.c14
-rw-r--r--lib/common.h2
2 files changed, 16 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);
+}
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