1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 01:00:20 +02:00

Ensure the signal-delivery thread is completely stopped before fork

* libguile/scmsigs.c: Use raw pthread_create / pthread_join instead of
Guile's scm_spawn_thread, to ensure that the thread is entirely stopped
before a fork.
* libguile/scmsigs.h (scm_i_is_signal_delivery_thread): New internal
procedure, replacing a manual check against scm_i_signal_delivery_thread.
* libguile/threads.c: Use the new procedure.

Based on a patch by Rob Browning.  Thanks!
This commit is contained in:
Andy Wingo 2024-06-21 11:11:46 +02:00
parent 0a8a1eb595
commit d7ed457620
3 changed files with 89 additions and 31 deletions

View file

@ -1,4 +1,4 @@
/* Copyright 1995-1998,2000-2014,2018-2019,2023
/* Copyright 1995-1998,2000-2014,2018-2019,2023-2024
Free Software Foundation, Inc.
This file is part of Guile.
@ -492,9 +492,8 @@ on_thread_exit (void *v)
t->handle = SCM_PACK (0);
/* If there's only one other thread, it could be the signal delivery
thread, so we need to notify it to shut down by closing its read pipe.
If it's not the signal delivery thread, then closing the read pipe isn't
going to hurt. */
thread, in which case we should shut it down also by closing its
read pipe. */
if (thread_count <= 1)
scm_i_close_signal_pipe ();
@ -1692,9 +1691,7 @@ SCM_DEFINE (scm_all_threads, "all-threads", 0, 0, 0,
for (t = all_threads; t && n > 0; t = t->next_thread)
{
if (!t->exited
&& (scm_is_false (scm_i_signal_delivery_thread)
|| (!scm_is_eq (t->handle, scm_i_signal_delivery_thread))))
if (!t->exited && !scm_i_is_signal_delivery_thread (t))
{
SCM_SETCAR (*l, t->handle);
l = SCM_CDRLOC (*l);