commit-hurd
[Top][All Lists]
Advanced

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

[hurd] 05/05: proc: Refactor.


From: Samuel Thibault
Subject: [hurd] 05/05: proc: Refactor.
Date: Fri, 10 Mar 2017 03:33:19 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch upstream
in repository hurd.

commit 150ff2ad69344d8555c14b42b2658313f16e9d1e
Author: Justus Winter <address@hidden>
Date:   Thu Mar 9 23:51:54 2017 +0100

    proc: Refactor.
    
    * proc/mgt.c (namespace_find_root): New function.
    (process_has_exited): Use new function.
    * proc/proc.h (namespace_find_root): New declaration.
---
 proc/mgt.c  | 25 +++++++++++++++++--------
 proc/proc.h |  1 +
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/proc/mgt.c b/proc/mgt.c
index 831a351..87a7c96 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 ffb54bf..c069614 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 *);

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

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