[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/7] proc: add proc_mark_essential server code
From: |
Justus Winter |
Subject: |
[PATCH 1/7] proc: add proc_mark_essential server code |
Date: |
Wed, 24 Jul 2013 08:30:53 +0200 |
This is a fragment of Guillem Jovers patch presented here:
http://lists.gnu.org/archive/html/bug-hurd/2006-02/msg00081.html
It has been refreshed and the copyright year is adjusted.
* proc/proc.h (struct proc): Add p_essential member.
* proc/pgrp.c (S_proc_getpgrppids): Exclude essential system processes.
(S_proc_mark_essential): New function.
* proc/mgt.c (create_startup_proc): Mark init as essential.
---
proc/mgt.c | 5 ++++-
proc/pgrp.c | 17 ++++++++++++++---
proc/proc.h | 3 ++-
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/proc/mgt.c b/proc/mgt.c
index 7af9c1a..c754a4b 100644
--- a/proc/mgt.c
+++ b/proc/mgt.c
@@ -1,5 +1,6 @@
/* Process management
- Copyright (C) 1992,93,94,95,96,99,2000,01,02 Free Software Foundation, Inc.
+ Copyright (C) 1992,93,94,95,96,99,2000,01,02,13
+ Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -592,6 +593,8 @@ create_startup_proc (void)
p->p_deadmsg = 1; /* Force initial "re-"fetch of msgport. */
+ p->p_essential = 1;
+
p->p_noowner = 0;
p->p_id = make_ids (&zero, 1);
assert (p->p_id);
diff --git a/proc/pgrp.c b/proc/pgrp.c
index 2d6ca93..3b5dba1 100644
--- a/proc/pgrp.c
+++ b/proc/pgrp.c
@@ -1,5 +1,5 @@
/* Session and process group manipulation
- Copyright (C) 1992,93,94,95,96,99,2001,02 Free Software Foundation, Inc.
+ Copyright (C) 1992,93,94,95,96,99,2001,02,13 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -265,7 +265,7 @@ S_proc_getpgrppids (struct proc *callerp,
count = 0;
for (p = pg->pg_plist; p; p = p->p_gnext)
- if (++count <= npids)
+ if (++count <= npids && !p->p_essential)
*pp++ = p->p_pid;
if (count > npids)
@@ -278,7 +278,8 @@ S_proc_getpgrppids (struct proc *callerp,
pp = *pids;
for (p = pg->pg_plist; p; p = p->p_gnext)
- *pp++ = p->p_pid;
+ if (!p->p_essential)
+ *pp++ = p->p_pid;
/* Dealloc ? XXX */
}
*npidsp = count;
@@ -380,6 +381,16 @@ S_proc_mark_exec (struct proc *p)
return 0;
}
+/* Implement proc_mark_essential as described in <hurd/process.defs>. */
+kern_return_t
+S_proc_mark_essential (struct proc *p)
+{
+ if (!p)
+ return EOPNOTSUPP;
+ p->p_essential = 1;
+ return 0;
+}
+
/* Make process P no longer a member of its process group.
Note that every process is always a member of some process group;
this must be followed by setting P->p_pgrp and then calling
diff --git a/proc/proc.h b/proc/proc.h
index 247795d..bda2795 100644
--- a/proc/proc.h
+++ b/proc/proc.h
@@ -1,5 +1,5 @@
/* Process server definitions
- Copyright (C) 1992,93,94,95,96,99,2000,01 Free Software Foundation, Inc.
+ Copyright (C) 1992,93,94,95,96,99,2000,01,13 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -84,6 +84,7 @@ struct proc
unsigned int p_noowner:1; /* has no owner known */
unsigned int p_loginleader:1; /* leader of login collection */
unsigned int p_dead:1; /* process is dead */
+ unsigned int p_essential:1; /* has called proc_mark_essential */
};
typedef struct proc *pstruct_t;
--
1.7.10.4
- Re: /hurd/init and /hurd/proc, Samuel Thibault, 2013/07/15
- Re: /hurd/init and /hurd/proc, Roland McGrath, 2013/07/15
- kill (0, SIGSTOP) is freezing the system (was: /hurd/init and /hurd/proc), Justus Winter, 2013/07/24
- [PATCH 2/7] hurd: add proc_mark_essential, Justus Winter, 2013/07/24
- [PATCH 1/7] proc: add proc_mark_essential server code,
Justus Winter <=
- [PATCH 4/7] init: Build fixes, Justus Winter, 2013/07/24
- [PATCH 3/7] init: Mark auth, proc and fs servers as essential, Justus Winter, 2013/07/24
- [PATCH 6/7] proc: evil hack, mark all pids<100 essential, Justus Winter, 2013/07/24
- [PATCH 5/7] proc: Fix miscalculation of count, Justus Winter, 2013/07/24
- Re: kill (0, SIGSTOP) is freezing the system (was: /hurd/init and /hurd/proc), Samuel Thibault, 2013/07/24