]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: Cope with signals sent to ourself early
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 11 Jan 2025 23:09:44 +0000 (00:09 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 11 Jan 2025 23:55:56 +0000 (00:55 +0100)
Typically when aborting during initialization, before signals are set
up.

sysdeps/mach/hurd/kill.c

index 1e006ee1db44a7db005ca8eea77404c7a0181b3b..8cba3cc4ea1e5cba7a82103919dd02fa99270b7a 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.