Skip to content

Commit 8ed2bd8

Browse files
committed
clear need_locks in child after fork
the child is single-threaded, but may still need to synchronize with last changes made to memory by another thread in the parent, so set need_locks to -1 whereby the next lock-taker will drop to 0 and prevent further barriers/locking.
1 parent fca7428 commit 8ed2bd8

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/process/fork.c

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pid_t fork(void)
3030
self->next = self->prev = self;
3131
__thread_list_lock = 0;
3232
libc.threads_minus_1 = 0;
33+
if (libc.need_locks) libc.need_locks = -1;
3334
}
3435
__restore_sigs(&set);
3536
__fork_handler(!ret);

0 commit comments

Comments
 (0)