Run pthread_atfork only once

Close #7704
This commit is contained in:
topjohnwu
2024-01-25 00:17:05 -08:00
parent b44141ae39
commit f2c4288d2d
4 changed files with 8 additions and 2 deletions
+4 -2
View File
@@ -42,8 +42,6 @@ static void reset_pool() {
}
static void *thread_pool_loop(void * const is_core_pool) {
pthread_atfork(nullptr, nullptr, &reset_pool);
// Block all signals
sigset_t mask;
sigfillset(&mask);
@@ -83,6 +81,10 @@ static void *thread_pool_loop(void * const is_core_pool) {
}
}
void init_thread_pool() {
pthread_atfork(nullptr, nullptr, &reset_pool);
}
void exec_task(function<void()> &&task) {
mutex_guard g(lock);
pending_task.swap(task);