Index: kern_resource.c =================================================================== RCS file: /usr/repo/src/sys/kern/kern_resource.c,v retrieving revision 1.180 diff -u -p -r1.180 kern_resource.c --- kern_resource.c 17 Jul 2007 01:08:09 -0000 1.180 +++ kern_resource.c 30 Sep 2007 08:07:36 -0000 @@ -104,7 +104,8 @@ getpriority(td, uap) p = pfind(uap->who); if (p == NULL) break; - if (p_cansee(td, p) == 0) + error = p_cansee(td, p); + if (error == 0) low = p->p_nice; PROC_UNLOCK(p); } @@ -125,7 +126,7 @@ getpriority(td, uap) sx_sunlock(&proctree_lock); LIST_FOREACH(p, &pg->pg_members, p_pglist) { PROC_LOCK(p); - if (!p_cansee(td, p)) { + if (p_cansee(td, p) == 0) { if (p->p_nice < low) low = p->p_nice; } @@ -143,7 +144,7 @@ getpriority(td, uap) if (p->p_state == PRS_NEW) continue; PROC_LOCK(p); - if (!p_cansee(td, p) && + if (p_cansee(td, p) == 0 && p->p_ucred->cr_uid == uap->who) { if (p->p_nice < low) low = p->p_nice; @@ -177,7 +178,7 @@ setpriority(td, uap) { struct proc *curp, *p; struct pgrp *pg; - int found = 0, error = 0; + int error = ESRCH; curp = td->td_proc; switch (uap->which) { @@ -188,13 +189,13 @@ setpriority(td, uap) PROC_UNLOCK(curp); } else { p = pfind(uap->who); - if (p == 0) + if (p == NULL) break; - if (p_cansee(td, p) == 0) + error = p_cansee(td, p); + if (error == 0) error = donice(td, p, uap->prio); PROC_UNLOCK(p); } - found++; break; case PRIO_PGRP: @@ -212,10 +213,8 @@ setpriority(td, uap) sx_sunlock(&proctree_lock); LIST_FOREACH(p, &pg->pg_members, p_pglist) { PROC_LOCK(p); - if (!p_cansee(td, p)) { + if (p_cansee(td, p) == 0) error = donice(td, p, uap->prio); - found++; - } PROC_UNLOCK(p); } PGRP_UNLOCK(pg); @@ -228,9 +227,8 @@ setpriority(td, uap) FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); if (p->p_ucred->cr_uid == uap->who && - !p_cansee(td, p)) { + p_cansee(td, p) == 0) { error = donice(td, p, uap->prio); - found++; } PROC_UNLOCK(p); } @@ -241,8 +239,6 @@ setpriority(td, uap) error = EINVAL; break; } - if (found == 0 && error == 0) - error = ESRCH; return (error); } @@ -282,7 +278,6 @@ struct rtprio_thread_args { int rtprio_thread(struct thread *td, struct rtprio_thread_args *uap) { - struct proc *curp; struct proc *p; struct rtprio rtp; struct thread *td1; @@ -294,12 +289,11 @@ rtprio_thread(struct thread *td, struct else cierror = 0; - curp = td->td_proc; /* * Though lwpid is unique, only current process is supported * since there is no efficient way to look up a LWP yet. */ - p = curp; + p = td->td_proc; PROC_LOCK(p); switch (uap->function) { @@ -374,7 +368,6 @@ rtprio(td, uap) struct thread *td; /* curthread */ register struct rtprio_args *uap; { - struct proc *curp; struct proc *p; struct thread *tdp; struct rtprio rtp; @@ -386,9 +379,8 @@ rtprio(td, uap) else cierror = 0; - curp = td->td_proc; if (uap->pid == 0) { - p = curp; + p = td->td_proc; PROC_LOCK(p); } else { p = pfind(uap->pid);