Browse Source

Don't permit any signal delivery to threads on Linux

gingerBill 4 years ago
parent
commit
a852c17614
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/threading.cpp

+ 6 - 1
src/threading.cpp

@@ -356,7 +356,12 @@ void gb__thread_run(Thread *t) {
 		return 0;
 	}
 #else
-	void *          internal_thread_proc(void *arg) {
+	void *internal_thread_proc(void *arg) {
+		// NOTE: Don't permit any signal delivery to threads.
+		sigset_t mask = {};
+		sigfillset(&mask);
+		GB_ASSERT_MSG(pthread_sigmask(SIG_BLOCK, &mask, nullptr) == 0, "failed to block signals");
+		
 		Thread *t = cast(Thread *)arg;
 		gb__thread_run(t);
 		t->is_running.store(false);