GNU bug report logs - #46403
SIGINT ignored when using system*

Previous Next

Package: guile;

Reported by: Ricardo Wurmus <rekado <at> elephly.net>

Date: Tue, 9 Feb 2021 13:57:02 UTC

Severity: normal

To reply to this bug, email your comments to 46403 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#46403; Package guile. (Tue, 09 Feb 2021 13:57:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ricardo Wurmus <rekado <at> elephly.net>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Tue, 09 Feb 2021 13:57:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ricardo Wurmus <rekado <at> elephly.net>
To: bug-guile <at> gnu.org
Subject: SIGINT ignored when using system*
Date: Tue, 09 Feb 2021 14:56:06 +0100
I execute commands in a loop and wish to be able to interrupt the loop
with SIGINT.  Here’s the first attempt:

    guile -c \
      '(for-each (lambda (n)
                  (display n)
                  (system* "sleep" "3"))
                 (list 1 2 3 4))'

At no point will this program be interrupted by SIGINT.  Strace reveals
that SIGINT is in fact received and the sleep is interrupted, but the
wait is restarted immediately afterward.

This program on the other hand *can* be interrupted at any point:

    guile -c \
      '(for-each (lambda (n)
                  (if (zero? (primitive-fork))
                   (begin (display n)
                          (execlp "sleep" "sleep" "3"))
                   (waitpid WAIT_ANY)))
                 (list 1 2 3 4))'

Is this by design?

-- 
Ricardo




Information forwarded to bug-guile <at> gnu.org:
bug#46403; Package guile. (Sat, 01 May 2021 23:20:01 GMT) Full text and rfc822 format available.

Message #8 received at 46403 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Ricardo Wurmus <rekado <at> elephly.net>
Cc: 46403 <at> debbugs.gnu.org
Subject: Re: bug#46403: SIGINT ignored when using system*
Date: Sun, 02 May 2021 01:19:10 +0200
Hi!

Ricardo Wurmus <rekado <at> elephly.net> skribis:

> I execute commands in a loop and wish to be able to interrupt the loop
> with SIGINT.  Here’s the first attempt:
>
>     guile -c \
>       '(for-each (lambda (n)
>                   (display n)
>                   (system* "sleep" "3"))
>                  (list 1 2 3 4))'
>
> At no point will this program be interrupted by SIGINT.  Strace reveals
> that SIGINT is in fact received and the sleep is interrupted, but the
> wait is restarted immediately afterward.

‘system*’ explicitly ignores SIGINT:

--8<---------------cut here---------------start------------->8---
  /* Make sure the child can't kill us (as per normal system call).  */
  scm_dynwind_sigaction (SIGINT,
                         scm_from_uintptr_t ((uintptr_t) SIG_IGN),
                         SCM_UNDEFINED);
--8<---------------cut here---------------end--------------->8---

Indeed, system(3) says:

   During  execution  of  the command, SIGCHLD will be blocked, and SIGINT
   and SIGQUIT will be  ignored,  in  the  process  that  calls  system().
   (These  signals  will be handled according to their defaults inside the
   child process that executes command.)

(I did some archaeology and found it has always been this way since Rob
introduced ‘system*’ in 0db17ef9abd59da51ebc30d90fb2dc482b02a4a1.)

> Is this by design?

I think so!

Ludo’.




This bug report was last modified 3 years and 206 days ago.

Previous Next


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