bug-hurd
[Top][All Lists]
Advanced

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

[PATCH 1/2] Hurd: make reboot() send messages to both pid 1 and 2


From: Justus Winter
Subject: [PATCH 1/2] Hurd: make reboot() send messages to both pid 1 and 2
Date: Thu, 15 Aug 2013 10:43:34 +0200

Previously /hurd/init was run as pid 1 on Hurd systems, however
sysvinit assumes that it is being run as pid 1. To appease sysvinit,
/hurd/init will be run as pid 2 in the near future.

Currently the pid of /hurd/init is hardcoded to 1. This patch makes
reboot() try to send the start_reboot message to pid 1, and if that
fails it will send it to pid 2.

* sysdeps/mach/hurd/reboot.c (reboot): Try to send a startup_reboot
  message to both pid 1 and 2.
---
 ChangeLog                  |    5 +++++
 sysdeps/mach/hurd/reboot.c |   13 +++++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fa588c9..0274da9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-08-08  Justus Winter  <address@hidden>
+
+       * sysdeps/mach/hurd/reboot.c (reboot): Try to send a
+       startup_reboot message to both pid 1 and 2.
+
 2013-08-03  David S. Miller  <address@hidden>
 
        * po/ko.po: Update Korean translation from translation project.
diff --git a/sysdeps/mach/hurd/reboot.c b/sysdeps/mach/hurd/reboot.c
index 60d96ea..e23215a 100644
--- a/sysdeps/mach/hurd/reboot.c
+++ b/sysdeps/mach/hurd/reboot.c
@@ -33,11 +33,16 @@ reboot (int howto)
   if (err)
     return __hurd_fail (EPERM);
 
-  err = __USEPORT (PROC, __proc_getmsgport (port, 1, &init));
-  if (!err)
+  for (pid_t pid = 1; pid < 3; pid++)
     {
-      err = __startup_reboot (init, hostpriv, howto);
-      __mach_port_deallocate (__mach_task_self (), init);
+      err = __USEPORT (PROC, __proc_getmsgport (port, pid, &init));
+      if (!err)
+       {
+         err = __startup_reboot (init, hostpriv, howto);
+         __mach_port_deallocate (__mach_task_self (), init);
+         if (!err)
+           break;
+       }
     }
 
   __mach_port_deallocate (__mach_task_self (), hostpriv);
-- 
1.7.10.4




reply via email to

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