git-early-kill
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Sat, 15 Feb 2025 10:20:09 +0000 (11:20 +0100)
committerAurelien Jarno <aurel32@debian.org>
Sat, 15 Feb 2025 10:20:09 +0000 (11:20 +0100)
commit 0c4856250814d5fe1222a39c6954c4b5d79a829c
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Sun Jan 12 00:09:44 2025 +0100

    hurd: Cope with signals sent to ourself early

    Typically when aborting during initialization, before signals are set
    up.

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name git-early-kill.diff

sysdeps/mach/hurd/kill.c

index 83f586a4c9a055ab198e9fae3afa9c24357d68f5..9ac3a55c15da23ca51cc243c86e9e7701c5bd6fb 100644 (file)
@@ -17,7 +17,9 @@
 
 #include <errno.h>
 #include <sys/types.h>
+#include <sys/wait.h>
 #include <signal.h>
+#include <unistd.h>
 #include <hurd.h>
 #include <hurd/port.h>
 #include <hurd/signal.h>
@@ -34,6 +36,14 @@ __kill (pid_t pid, int sig)
   mach_port_t proc;
   struct hurd_userlink ulink;
 
+  if (pid == __getpid () && _hurd_msgport == MACH_PORT_NULL)
+    {
+      /* We are trying to kill ourself but we have not even initialized our own
+         msgport yet.  Abort by hand.  */
+      _exit (127);
+      /* NOTREACHED */
+    }
+
   void kill_pid (pid_t pid) /* Kill one PID.  */
     {
       /* SIGKILL is not delivered as a normal signal.