]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: Prevent the final file_exec_paths call from signals
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 20 Nov 2023 18:19:50 +0000 (19:19 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 20 Nov 2023 22:28:16 +0000 (23:28 +0100)
Otherwise if the exec server started thrashing the old task,
we won't be able to restart the exec.

This notably fixes building ghc.

hurd/hurdexec.c
sysdeps/mach/hurd/spawni.c

index e358d846c8a230866755102e89ee4f9e70acdffc..317d7ea0adf82cc553e8ed044dca0ea4bdff046b 100644 (file)
@@ -362,6 +362,7 @@ retry:
   if (!err)
     {
       int flags;
+      sigset_t old, new;
 
       if (pdp)
        {
@@ -420,6 +421,15 @@ retry:
       if (__sigismember (&_hurdsig_traced, SIGKILL))
        flags |= EXEC_SIGTRAP;
 #endif
+
+     /* Avoid getting interrupted while exec(), notably not after the exec
+        server has committed to the exec and started thrashing us.
+
+        TODO Rather add proper interrupt support to the exec server, that
+        avoids interrupts in that period.  */
+      __sigfillset (&new);
+      __sigprocmask (SIG_SETMASK, &new, &old);
+
       err = __file_exec_paths (file, task, flags,
                               path ? path : "",
                               abspath ? abspath : "",
@@ -440,6 +450,8 @@ retry:
                           ints, INIT_INT_MAX,
                           please_dealloc, pdp - please_dealloc,
                           portnames, nportnames);
+
+      __sigprocmask (SIG_SETMASK, &old, NULL);
     }
 
   /* Release references to the standard ports.  */
index 9516001817785cd36cede1979df653ca077d4591..58a89b45f3fafcbc3abf8b30145f6ce7784c2622 100644 (file)
@@ -812,6 +812,18 @@ retry:
 
     inline error_t exec (file_t file)
       {
+       sigset_t old, new;
+
+       /* Avoid getting interrupted while exec(), notably not after the exec
+          server has committed to the exec and started thrashing the task.
+
+          Various issues otherwise show up when building e.g. ghc.
+
+          TODO Rather add proper interrupt support to the exec server, that
+          avoids interrupts in that period.  */
+       __sigfillset(&new);
+       __sigprocmask (SIG_SETMASK, &new, &old);
+
        error_t err = __file_exec_paths
          (file, task,
           __sigismember (&_hurdsig_traced, SIGKILL) ? EXEC_SIGTRAP : 0,
@@ -824,7 +836,7 @@ retry:
        /* Fallback for backwards compatibility.  This can just be removed
           when __file_exec goes away.  */
        if (err == MIG_BAD_ID)
-         return __file_exec (file, task,
+         err = __file_exec (file, task,
                              (__sigismember (&_hurdsig_traced, SIGKILL)
                              ? EXEC_SIGTRAP : 0),
                              args, argslen, env, envlen,
@@ -833,6 +845,8 @@ retry:
                              ints, INIT_INT_MAX,
                              NULL, 0, NULL, 0);
 
+       __sigprocmask (SIG_SETMASK, &old, NULL);
+
        return err;
       }