aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/signal.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/signal.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/signal.c b/src/signal.c
new file mode 100644
index 0000000..fc4ac8b
--- /dev/null
+++ b/src/signal.c
@@ -0,0 +1,23 @@
+#include "signal.h"
+#include "log.h"
+
+#include <pthread.h>
+#include <signal.h>
+
+volatile sig_atomic_t global_stop_flag = 0;
+
+int signal_set_thread_attr(pthread_attr_t *attr)
+{
+ sigset_t set;
+ sigemptyset(&set);
+ sigaddset(&set, SIGINT);
+ sigaddset(&set, SIGQUIT);
+ sigaddset(&set, SIGTERM);
+
+ if (pthread_attr_setsigmask_np(attr, &set)) {
+ print_errno("pthread_attr_setsigmask_np");
+ return -1;
+ }
+
+ return 0;
+}