diff options
author | Ludovic Courtès <ludo@gnu.org> | 2024-01-05 18:54:38 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2024-01-05 18:59:58 +0100 |
commit | 5a8502a4946e8a5b5c40a127aa240fc6ad960d03 (patch) | |
tree | c6413cfdf9957a59ea13a47efd26978788ab3755 /libguile/posix.c | |
parent | a09214fb867846b12f1eb8ed91423636e511c1c7 (diff) | |
download | guile-5a8502a4946e8a5b5c40a127aa240fc6ad960d03.tar.gz |
Stop signal thread before forking, restart it afterwards.
Fixes <https://bugs.gnu.org/68087>.
* libguile/scmsigs.h (scm_i_signals_pre_fork, scm_i_signals_post_fork):
New declarations.
(scm_i_signal_delivery_thread): Change type to SCM..
* libguile/threads.c (scm_all_threads): Adjust accordingly and exclude
threads that have ‘t->exited’. Access ‘thread_count’ after grabbing
‘thread_admin_mutex’.
* libguile/posix.c (scm_fork): Add calls to ‘scm_i_signals_pre_fork’ and
‘scm_i_signals_post_fork’.
* libguile/scmsigs.c (signal_delivery_thread): Close signal_pipe[0] upon
exit and set it to -1.
(once): New file-global variable, moved from…
(scm_i_ensure_signal_delivery_thread): … here.
(stop_signal_delivery_thread, scm_i_signals_pre_fork)
(scm_i_signals_post_fork): New functions.
* test-suite/standalone/test-sigaction-fork: New file.
* test-suite/standalone/Makefile.am (check_SCRIPTS, TESTS): Add it.
Diffstat (limited to 'libguile/posix.c')
-rw-r--r-- | libguile/posix.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libguile/posix.c b/libguile/posix.c index 6ce78ee18..f7d68200b 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1295,7 +1295,10 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, #define FUNC_NAME s_scm_fork { int pid; + scm_i_finalizer_pre_fork (); + scm_i_signals_pre_fork (); + if (scm_ilength (scm_all_threads ()) != 1) /* Other threads may be holding on to resources that Guile needs -- it is not safe to permit one thread to fork while others are @@ -1317,6 +1320,9 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, if (pid == -1) SCM_SYSERROR; + + scm_i_signals_post_fork (); + return scm_from_int (pid); } #undef FUNC_NAME |