unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Foo Chuan Wei <chuanwei.foo@hotmail.com>
To: Ryan Prior <rprior@protonmail.com>, guix-devel@gnu.org
Subject: Re: Why does sh in the build environment ignore SIGINT and SIGQUIT?
Date: Tue, 24 May 2022 06:25:12 +0000	[thread overview]
Message-ID: <PU1PR01MB2155441FE4E48715E83255AA8DD79@PU1PR01MB2155.apcprd01.prod.exchangelabs.com> (raw)
In-Reply-To: <PU1PR01MB2155FAAF6E4E864B81D204ED8DD49@PU1PR01MB2155.apcprd01.prod.exchangelabs.com>

On 2022-05-23 03:14 +0000, Foo Chuan Wei wrote:
> `(invoke "sh" "-c" "trap")` is merely a trivial example for
> demonstrating that the shell ignores SIGINT and SIGQUIT. This might be
> significant if the build step invokes the shell to do something more
> significant (e.g. to build something).
> 
> Anyway, I found that this behavior is possibly related to one specified
> by POSIX [1]:
> 
> > 2.11. Signals and Error Handling
> >
> > If job control is disabled (see the description of set -m) when the
> > shell executes an asynchronous list, the commands in the list shall
> > inherit from the shell a signal action of ignored (SIG_IGN) for the
> > SIGINT and SIGQUIT signals.

Maybe not. Guix's `invoke` procedure uses Guile's `system*` procedure,
which ignores SIGINT and SIGQUIT as can be seen in Guile's source code:
https://git.savannah.gnu.org/cgit/guile.git/tree/libguile/posix.c?h=v3.0.8#n1524

> Do you have a solution to this problem?

Guile's `system` procedure does not have this problem (compare
`(system "bash -c trap")` with `(system* "bash" "-c" "trap")`).
One possible solution is to replace `invoke` with `system`:


diff --git a/gnu/packages/sml.scm b/gnu/packages/sml.scm
index 04411c02c3..fafdba9a3f 100644
--- a/gnu/packages/sml.scm
+++ b/gnu/packages/sml.scm
@@ -175,10 +175,14 @@ function interface, and a symbolic debugger.")
                        "sml.boot.amd64-unix/SMLNJ-BASIS/.cm/amd64-unix/basis-common.cm"))
 
              ;; Build.
-             (invoke "./config/install.sh" "-default"
-                     (if (string=? "i686-linux" ,(%current-system))
-                       "32"
-                       "64"))
+             (let ((exit-code
+                     (system (string-append "./config/install.sh -default "
+                                            (if (string=? "i686-linux"
+                                                          ,(%current-system))
+                                                "32"
+                                                "64")))))
+               (unless (zero? exit-code)
+                 (error (format #f "Exit code: ~a" exit-code))))
 
              ;; Undo the binary patch.
              (for-each



  reply	other threads:[~2022-05-24  6:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-22  8:00 Why does sh in the build environment ignore SIGINT and SIGQUIT? Foo Chuan Wei
2022-05-22 14:14 ` Ryan Prior
2022-05-23  3:14   ` Foo Chuan Wei
2022-05-24  6:25     ` Foo Chuan Wei [this message]
2022-05-24 23:28       ` Kaelyn
2022-05-30 15:20 ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PU1PR01MB2155441FE4E48715E83255AA8DD79@PU1PR01MB2155.apcprd01.prod.exchangelabs.com \
    --to=chuanwei.foo@hotmail.com \
    --cc=guix-devel@gnu.org \
    --cc=rprior@protonmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).