diff options
-rw-r--r-- | proc/mgt.c | 35 | ||||
-rw-r--r-- | proc/pgrp.c | 7 | ||||
-rw-r--r-- | proc/proc.h | 1 |
3 files changed, 40 insertions, 3 deletions
@@ -593,6 +593,8 @@ create_startup_proc (void) p->p_deadmsg = 1; /* Force initial "re-"fetch of msgport. */ + p->p_important = 1; + p->p_noowner = 0; p->p_id = make_ids (&zero, 1); assert (p->p_id); @@ -868,3 +870,36 @@ genpid () return nextpid++; } + +/* Implement proc_mark_important as described in <hurd/process.defs>. */ +kern_return_t +S_proc_mark_important (struct proc *p) +{ + if (!p) + return EOPNOTSUPP; + + /* Only root may use this interface. Any children of startup_proc + exempt from this restriction, as startup_proc calls this on their + behalf. The kernel process is a notable example of an process + that needs this exemption. That is not an problem however, since + all children of /hurd/init are important and we mark them as such + anyway. */ + if (! check_uid (p, 0) && ! check_owner (startup_proc, p)) + return EPERM; + + p->p_important = 1; + return 0; +} + +/* Implement proc_is_important as described in <hurd/process.defs>. */ +error_t +S_proc_is_important (struct proc *callerp, + boolean_t *essential) +{ + if (!callerp) + return EOPNOTSUPP; + + *essential = callerp->p_important; + + return 0; +} diff --git a/proc/pgrp.c b/proc/pgrp.c index 2d6ca93a..d4ea9ee4 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 (!p->p_important && ++count <= npids) *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_important) + *pp++ = p->p_pid; /* Dealloc ? XXX */ } *npidsp = count; diff --git a/proc/proc.h b/proc/proc.h index b7a95662..ed47cccb 100644 --- a/proc/proc.h +++ b/proc/proc.h @@ -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_important:1; /* has called proc_mark_important */ }; typedef struct proc *pstruct_t; |