unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#46403: SIGINT ignored when using system*
@ 2021-02-09 13:56 Ricardo Wurmus
  2021-05-01 23:19 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Ricardo Wurmus @ 2021-02-09 13:56 UTC (permalink / raw)
  To: 46403

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#46403: SIGINT ignored when using system*
  2021-02-09 13:56 bug#46403: SIGINT ignored when using system* Ricardo Wurmus
@ 2021-05-01 23:19 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2021-05-01 23:19 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: 46403

Hi!

Ricardo Wurmus <rekado@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’.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-01 23:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09 13:56 bug#46403: SIGINT ignored when using system* Ricardo Wurmus
2021-05-01 23:19 ` Ludovic Courtès

unofficial mirror of bug-guile@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-bugs/0 guile-bugs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-bugs guile-bugs/ https://yhetil.org/guile-bugs \
		bug-guile@gnu.org
	public-inbox-index guile-bugs

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.bugs
	nntp://news.gmane.io/gmane.lisp.guile.bugs


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git