aboutsummaryrefslogtreecommitdiff
path: root/proc
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2017-03-09 23:51:54 +0100
committerJustus Winter <justus@gnupg.org>2017-03-09 23:55:41 +0100
commit150ff2ad69344d8555c14b42b2658313f16e9d1e (patch)
tree53d00a5d93e81ec3ecef541fbf8874c2ee8e1288 /proc
parentfb3698ebbb375472832939d5534363d42de624f2 (diff)
downloadhurd-150ff2ad69344d8555c14b42b2658313f16e9d1e.tar.gz
hurd-150ff2ad69344d8555c14b42b2658313f16e9d1e.tar.bz2
hurd-150ff2ad69344d8555c14b42b2658313f16e9d1e.zip
proc: Refactor.
* proc/mgt.c (namespace_find_root): New function. (process_has_exited): Use new function. * proc/proc.h (namespace_find_root): New declaration.
Diffstat (limited to 'proc')
-rw-r--r--proc/mgt.c25
-rw-r--r--proc/proc.h1
2 files changed, 18 insertions, 8 deletions
diff --git a/proc/mgt.c b/proc/mgt.c
index 831a3510..87a7c96b 100644
--- a/proc/mgt.c
+++ b/proc/mgt.c
@@ -733,6 +733,22 @@ new_proc (task_t task)
return p;
}
+/* Find the creator of the task namespace that P is in. */
+struct proc *
+namespace_find_root (struct proc *p)
+{
+ for (;
+ MACH_PORT_VALID (p->p_parent->p_task_namespace);
+ p = p->p_parent)
+ {
+ /* Walk up the process hierarchy until we find the creator of
+ the task namespace. The last process we encounter that has a
+ valid task_namespace must be the creator. */
+ }
+
+ return p;
+}
+
/* Used with prociterate to terminate all tasks in a task
namespace. */
static void
@@ -785,14 +801,7 @@ process_has_exited (struct proc *p)
if (MACH_PORT_VALID (p->p_task_namespace))
{
- for (tp = p;
- MACH_PORT_VALID (tp->p_parent->p_task_namespace);
- tp = tp->p_parent)
- {
- /* Walk up the process hierarchy until we find the
- creator of the task namespace. */
- }
-
+ tp = namespace_find_root (p);
if (p == tp)
{
/* The creator of the task namespace died. Terminate
diff --git a/proc/proc.h b/proc/proc.h
index ffb54bf0..c0696149 100644
--- a/proc/proc.h
+++ b/proc/proc.h
@@ -201,6 +201,7 @@ void leave_pgrp (struct proc *);
void join_pgrp (struct proc *);
void boot_setsid (struct proc *);
+struct proc *namespace_find_root (struct proc *);
void process_has_exited (struct proc *);
void alert_parent (struct proc *);
void reparent_zombies (struct proc *);