GNU bug report logs - #68087
Signal handlers not called after ‘primitive-fork’

Previous Next

Package: guile;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Thu, 28 Dec 2023 17:18:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Ludovic Courtès <ludo <at> gnu.org>
Subject: bug#68087: closed (Re: bug#68087: Signal handlers not called
 after ‘primitive-fork’)
Date: Wed, 24 Jan 2024 10:36:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#68087: Signal handlers not called after ‘primitive-fork’

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 68087 <at> debbugs.gnu.org.

-- 
68087: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68087
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Ludovic Courtès <ludo <at> gnu.org>
To: 68087-done <at> debbugs.gnu.org
Subject: Re: bug#68087: Signal handlers not called after
 ‘primitive-fork’
Date: Wed, 24 Jan 2024 11:34:57 +0100
Ludovic Courtès <ludo <at> gnu.org> skribis:

> 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.

Pushed as 5a8502a4946e8a5b5c40a127aa240fc6ad960d03.

Ludo’.

[Message part 3 (message/rfc822, inline)]
From: Ludovic Courtès <ludo <at> gnu.org>
To: bug-guile <at> gnu.org
Subject: Signal handlers not called after ‘primitive-fork’
Date: Thu, 28 Dec 2023 18:16:52 +0100
In 3.0.9 and current ‘main’, I get this:

--8<---------------cut here---------------start------------->8---
$ cat sigaction-fork.scm
(use-modules (ice-9 match))

;; This call spawns the signal delivery thread as a side effect.
(sigaction SIGALRM
  (lambda (signal)
    (pk 'got-signal! signal)))

(match (primitive-fork)
  (0
   (pk 'child (getpid))
   (sigaction SIGALRM
     (lambda (signal)
       ;; This handler is never called!
       (pk 'got-signal-child! signal)))
   (kill 0 SIGALRM)
   (pk 'alarm-sent))
  (_
   (primitive-exit 0)))
$ guile sigaction-fork.scm

;;; (child 30308)

;;; (alarm-sent)
--8<---------------cut here---------------end--------------->8---

Everything works fine if we remove the pre-fork ‘sigaction’ call.

Ludo’.



This bug report was last modified 1 year and 197 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.