aboutsummaryrefslogtreecommitdiff
path: root/proc/info.c
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1996-04-25 19:36:50 +0000
committerMichael I. Bushnell <mib@gnu.org>1996-04-25 19:36:50 +0000
commitfac6d9a6d59a83e96314103b3181f6f692537014 (patch)
tree7c85f3bab7e22f0c603bdbcc69d65ff210d5d354 /proc/info.c
parent73eae492a741dbe1b2bcd919374bea8c328a4e45 (diff)
downloadhurd-fac6d9a6d59a83e96314103b3181f6f692537014.tar.gz
hurd-fac6d9a6d59a83e96314103b3181f6f692537014.tar.bz2
hurd-fac6d9a6d59a83e96314103b3181f6f692537014.zip
Many changes to support multi-threading. See ChangeLog.
Diffstat (limited to 'proc/info.c')
-rw-r--r--proc/info.c49
1 files changed, 45 insertions, 4 deletions
diff --git a/proc/info.c b/proc/info.c
index b0b2feff..936345b9 100644
--- a/proc/info.c
+++ b/proc/info.c
@@ -38,11 +38,20 @@ S_proc_pid2task (struct proc *callerp,
pid_t pid,
task_t *t)
{
- struct proc *p = pid_find (pid);
+ struct proc *p = pid_find_allow_zombie (pid);
+
+ if (!callerp)
+ return EOPNOTSUPP;
if (!p)
return ESRCH;
+ if (p->p_dead)
+ {
+ *t = MACH_PORT_NULL;
+ return 0;
+ }
+
if (!check_uid (callerp, p->p_owner))
return EPERM;
*t = p->p_task;
@@ -58,6 +67,8 @@ S_proc_task2pid (struct proc *callerp,
{
struct proc *p = task_find (t);
+ /* No need to check CALLERP here; we don't use it. */
+
if (!p)
return ESRCH;
@@ -74,10 +85,12 @@ S_proc_task2proc (struct proc *callerp,
{
struct proc *p = task_find (t);
+ /* No need to check CALLERP here; we don't use it. */
+
if (!p)
return ESRCH;
- *outproc = p->p_reqport;
+ *outproc = ports_get_right (p);
mach_port_deallocate (mach_task_self (), t);
return 0;
}
@@ -87,6 +100,8 @@ kern_return_t
S_proc_proc2task (struct proc *p,
task_t *t)
{
+ if (!p)
+ return EOPNOTSUPP;
*t = p->p_task;
return 0;
}
@@ -97,15 +112,24 @@ S_proc_pid2proc (struct proc *callerp,
pid_t pid,
mach_port_t *outproc)
{
- struct proc *p = pid_find (pid);
+ struct proc *p = pid_find_allow_zombie (pid);
+
+ if (!callerp)
+ return EOPNOTSUPP;
if (!p)
return ESRCH;
+ if (p->p_dead)
+ {
+ *outproc = MACH_PORT_NULL;
+ return 0;
+ }
+
if (!check_uid (callerp, p->p_owner))
return EPERM;
- *outproc = p->p_reqport;
+ *outproc = ports_get_right (p);
return 0;
}
@@ -289,6 +313,8 @@ S_proc_getprocargs (struct proc *callerp,
{
struct proc *p = pid_find (pid);
+ /* No need to check CALLERP here; we don't use it. */
+
if (!p)
return ESRCH;
@@ -304,6 +330,8 @@ S_proc_getprocenv (struct proc *callerp,
{
struct proc *p = pid_find (pid);
+ /* No need to check CALLERP here; we don't use it. */
+
if (!p)
return ESRCH;
@@ -332,6 +360,8 @@ S_proc_getprocinfo (struct proc *callerp,
u_int tkcount, thcount;
struct proc *tp;
+ /* No need to check CALLERP here; we don't use it. */
+
if (!p)
return ESRCH;
@@ -508,6 +538,8 @@ S_proc_getprocinfo (struct proc *callerp,
kern_return_t
S_proc_make_login_coll (struct proc *p)
{
+ if (!p)
+ return EOPNOTSUPP;
p->p_loginleader = 1;
return 0;
}
@@ -521,6 +553,8 @@ S_proc_getloginid (struct proc *callerp,
struct proc *proc = pid_find (pid);
struct proc *p;
+ /* No need to check CALLERP here; we don't use it. */
+
if (!proc)
return ESRCH;
@@ -544,6 +578,8 @@ S_proc_getloginpids (struct proc *callerp,
int parraysize;
int i;
+ /* No need to check CALLERP here; we don't use it. */
+
if (!l || !l->p_loginleader)
return ESRCH;
@@ -587,6 +623,9 @@ S_proc_setlogin (struct proc *p,
{
struct login *l;
+ if (!p)
+ return EOPNOTSUPP;
+
if (!check_uid (p, 0))
return EPERM;
@@ -604,6 +643,8 @@ kern_return_t
S_proc_getlogin (struct proc *p,
char *login)
{
+ if (!p)
+ return EOPNOTSUPP;
strcpy (login, p->p_login->l_name);
return 0;
}