[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 08/17] init: Mark all of inits children and init itself as import
From: |
Justus Winter |
Subject: |
[PATCH 08/17] init: Mark all of inits children and init itself as important |
Date: |
Thu, 15 Aug 2013 09:37:58 +0200 |
This is based on a fragment of Guillem Jovers patch presented here:
http://lists.gnu.org/archive/html/bug-hurd/2006-02/msg00081.html
It has been refreshed, updated and the copyright year is adjusted
properly. It has been complemented with the necessary features to
address the issues the original patch set out to address, namely
that killall5 freezes the proc translator before it tries to walk
over /proc/*/stat to decide which process to kill. Prior to this
patch (and the one marking the procfs server as important
process), killall5 would deadlock trying to walk over the proc
file system.
Ironically it would not have killed any process later on even if
it had the chance, since two values obtained from /proc/*/stat
are currently hardcoded to zero in our procfs. Patches addressing
the problem as a whole are prepared and will be sent as a follow
up.
* init/init.c (launch_core_servers): Mark init, auth, proc and fs
servers as important.
(start_child): Mark the real init as important.
(S_startup_important_task): Mark exec server as important.
---
init/init.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/init/init.c b/init/init.c
index 09b657b..9982558 100644
--- a/init/init.c
+++ b/init/init.c
@@ -1,7 +1,7 @@
/* Start and maintain hurd core servers and system run state
Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
- 2005, 2008 Free Software Foundation, Inc.
+ 2005, 2008, 2013 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
The GNU Hurd is free software; you can redistribute it and/or modify
@@ -643,6 +643,8 @@ launch_core_servers (void)
device_master = 0;
}
+ /* Mark us as important. */
+ proc_mark_important (procserver);
proc_mark_exec (procserver);
/* Declare that the filesystem and auth are our children. */
@@ -650,6 +652,7 @@ launch_core_servers (void)
proc_child (procserver, authtask);
proc_task2proc (procserver, authtask, &authproc);
+ proc_mark_important (authproc);
proc_mark_exec (authproc);
startup_authinit_reply (authreply, authreplytype, 0, authproc,
MACH_MSG_TYPE_COPY_SEND);
@@ -672,6 +675,7 @@ launch_core_servers (void)
err = proc_task2proc (procserver, proctask, &procproc);
if (!err)
{
+ proc_mark_important (procproc);
proc_mark_exec (procproc);
mach_port_deallocate (mach_task_self (), procproc);
}
@@ -681,6 +685,7 @@ launch_core_servers (void)
/* Get the bootstrap filesystem's proc server port.
We must do this before calling proc_setmsgport below. */
proc_task2proc (procserver, fstask, &fsproc);
+ proc_mark_important (fsproc);
proc_mark_exec (fsproc);
#if 0
@@ -785,8 +790,10 @@ frob_kernel_process (void)
return;
}
- /* Mark the kernel task as an essential task so that we never
- want to task_terminate it. */
+ /* Mark the kernel task as an essential task so that we or the proc server
+ never want to task_terminate it. */
+ proc_mark_important (proc);
+
err = record_essential_task ("kernel", task);
assert_perror (err);
@@ -1067,6 +1074,7 @@ start_child (const char *prog, char **progargs)
default_ports, MACH_MSG_TYPE_COPY_SEND, INIT_PORT_MAX,
default_ints, INIT_INT_MAX,
NULL, 0, NULL, 0);
+ proc_mark_important (default_ports[INIT_PORT_PROC]);
mach_port_deallocate (mach_task_self (), default_ports[INIT_PORT_PROC]);
mach_port_deallocate (mach_task_self (), file);
if (err)
@@ -1207,7 +1215,12 @@ S_startup_essential_task (mach_port_t server,
if (!strcmp (name, "auth"))
authinit = 1;
else if (!strcmp (name, "exec"))
- execinit = 1;
+ {
+ execinit = 1;
+ mach_port_t execproc;
+ proc_task2proc (procserver, task, &execproc);
+ proc_mark_important (execproc);
+ }
else if (!strcmp (name, "proc"))
procinit = 1;
--
1.7.10.4
- Re: [PATCH 01/17] hurd: add missing routines in process_reply.defs, daemons: fix setsid(2) in console-run, (continued)
- [PATCH 06/17] proc: add proc_mark_important server code, Justus Winter, 2013/08/15
- [PATCH 07/17] hurd: add proc_mark_important, Justus Winter, 2013/08/15
- [PATCH 08/17] init: Mark all of inits children and init itself as important,
Justus Winter <=
- [PATCH 09/17] libdiskfs: register libdiskfs-based translators as important, Justus Winter, 2013/08/15
- [PATCH 11/17] libtrivfs: register libtrivfs-based translators as important, Justus Winter, 2013/08/15
- [PATCH 10/17] libnetfs: register libnetfs-based translators as important, Justus Winter, 2013/08/15
- [PATCH 12/17] mach-defpager: register mach-defpager translators as important, Justus Winter, 2013/08/15
- [PATCH 13/17] trans: register symlink translators as important, Justus Winter, 2013/08/15
- [PATCH 15/17] hurd: add proc_{get,set}_code, Justus Winter, 2013/08/15
- [PATCH 16/17] exec: keep track of the range where executable segments are mapped, Justus Winter, 2013/08/15
- [PATCH 14/17] proc: keep track of {start,end}_code, Justus Winter, 2013/08/15
- [PATCH 17/17] Build fixes: Build processUser.o and link against it, Justus Winter, 2013/08/15
[PATCH 1/2] Hurd: make reboot() send messages to both pid 1 and 2, Justus Winter, 2013/08/15