guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does sh in the build environment ignore SIGINT and SIGQUIT?


From: Foo Chuan Wei
Subject: Re: Why does sh in the build environment ignore SIGINT and SIGQUIT?
Date: Tue, 24 May 2022 06:25:12 +0000

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 via email to

[Prev in Thread] Current Thread [Next in Thread]