Just hold the proc lock while getting the parent's PID rather than a

proctree lock.
This commit is contained in:
jhb 2001-03-07 03:21:26 +00:00
parent 83d74ad162
commit 6b93e2c5c0
2 changed files with 10 additions and 20 deletions

View File

@ -363,18 +363,16 @@ linprocfs_doprocstat(curp, p, pfs, uio)
struct sbuf sb;
char *ps;
int r, xlen;
pid_t ppid;
PROCTREE_LOCK(PT_SHARED);
ppid = p->p_pptr ? p->p_pptr->p_pid : 0;
PROCTREE_LOCK(PT_RELEASE);
fill_kinfo_proc(p, &kp);
sbuf_new(&sb, NULL, 1024, 0);
sbuf_printf(&sb, "%d", p->p_pid);
#define PS_ADD(name, fmt, arg) sbuf_printf(&sb, " " fmt, arg)
PS_ADD("comm", "(%s)", p->p_comm);
PS_ADD("statr", "%c", '0'); /* XXX */
PS_ADD("ppid", "%d", ppid);
PROC_LOCK(p);
PS_ADD("ppid", "%d", p->p_pptr ? p->p_pptr->p_pid : 0);
PROC_UNLOCK(p);
PS_ADD("pgrp", "%d", p->p_pgid);
PS_ADD("session", "%d", p->p_session->s_sid);
PS_ADD("tty", "%d", 0); /* XXX */
@ -450,7 +448,6 @@ linprocfs_doprocstatus(curp, p, pfs, uio)
char *state;
int i, r, xlen;
segsz_t lsize;
pid_t ppid;
sbuf_new(&sb, NULL, 1024, 0);
@ -461,9 +458,6 @@ linprocfs_doprocstatus(curp, p, pfs, uio)
state = state_str[(int)p->p_stat];
mtx_unlock_spin(&sched_lock);
PROCTREE_LOCK(PT_SHARED);
ppid = p->p_pptr ? p->p_pptr->p_pid : 0;
PROCTREE_LOCK(PT_RELEASE);
fill_kinfo_proc(p, &kp);
sbuf_printf(&sb, "Name:\t%s\n", p->p_comm); /* XXX escape */
sbuf_printf(&sb, "State:\t%s\n", state);
@ -472,8 +466,9 @@ linprocfs_doprocstatus(curp, p, pfs, uio)
* Credentials
*/
sbuf_printf(&sb, "Pid:\t%d\n", p->p_pid);
sbuf_printf(&sb, "PPid:\t%d\n", ppid);
PROC_LOCK(p);
sbuf_printf(&sb, "PPid:\t%d\n", p->p_pptr ?
p->p_pptr->p_pid : 0);
sbuf_printf(&sb, "Uid:\t%d %d %d %d\n", p->p_cred->p_ruid,
p->p_ucred->cr_uid,
p->p_cred->p_svuid,

View File

@ -363,18 +363,16 @@ linprocfs_doprocstat(curp, p, pfs, uio)
struct sbuf sb;
char *ps;
int r, xlen;
pid_t ppid;
PROCTREE_LOCK(PT_SHARED);
ppid = p->p_pptr ? p->p_pptr->p_pid : 0;
PROCTREE_LOCK(PT_RELEASE);
fill_kinfo_proc(p, &kp);
sbuf_new(&sb, NULL, 1024, 0);
sbuf_printf(&sb, "%d", p->p_pid);
#define PS_ADD(name, fmt, arg) sbuf_printf(&sb, " " fmt, arg)
PS_ADD("comm", "(%s)", p->p_comm);
PS_ADD("statr", "%c", '0'); /* XXX */
PS_ADD("ppid", "%d", ppid);
PROC_LOCK(p);
PS_ADD("ppid", "%d", p->p_pptr ? p->p_pptr->p_pid : 0);
PROC_UNLOCK(p);
PS_ADD("pgrp", "%d", p->p_pgid);
PS_ADD("session", "%d", p->p_session->s_sid);
PS_ADD("tty", "%d", 0); /* XXX */
@ -450,7 +448,6 @@ linprocfs_doprocstatus(curp, p, pfs, uio)
char *state;
int i, r, xlen;
segsz_t lsize;
pid_t ppid;
sbuf_new(&sb, NULL, 1024, 0);
@ -461,9 +458,6 @@ linprocfs_doprocstatus(curp, p, pfs, uio)
state = state_str[(int)p->p_stat];
mtx_unlock_spin(&sched_lock);
PROCTREE_LOCK(PT_SHARED);
ppid = p->p_pptr ? p->p_pptr->p_pid : 0;
PROCTREE_LOCK(PT_RELEASE);
fill_kinfo_proc(p, &kp);
sbuf_printf(&sb, "Name:\t%s\n", p->p_comm); /* XXX escape */
sbuf_printf(&sb, "State:\t%s\n", state);
@ -472,8 +466,9 @@ linprocfs_doprocstatus(curp, p, pfs, uio)
* Credentials
*/
sbuf_printf(&sb, "Pid:\t%d\n", p->p_pid);
sbuf_printf(&sb, "PPid:\t%d\n", ppid);
PROC_LOCK(p);
sbuf_printf(&sb, "PPid:\t%d\n", p->p_pptr ?
p->p_pptr->p_pid : 0);
sbuf_printf(&sb, "Uid:\t%d %d %d %d\n", p->p_cred->p_ruid,
p->p_ucred->cr_uid,
p->p_cred->p_svuid,