This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 1/2] Hurd: make reboot() send messages to both pid 1 and 2
- From: Justus Winter <4winter at informatik dot uni-hamburg dot de>
- To: libc-alpha at sourceware dot org
- Cc: bug-hurd at gnu dot org, Samuel Thibault <samuel dot thibault at gnu dot org>, Justus Winter <4winter at informatik dot uni-hamburg dot de>
- Date: Thu, 15 Aug 2013 10:43:34 +0200
- Subject: [PATCH 1/2] Hurd: make reboot() send messages to both pid 1 and 2
- References: <1375697200-11572-1-git-send-email-4winter at informatik dot uni-hamburg dot de>
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 <4winter@informatik.uni-hamburg.de>
+
+ * 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 <davem@davemloft.net>
* 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