summaryrefslogtreecommitdiffstats
path: root/sys/compat/linprocfs
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-03-07 03:21:26 +0000
committerjhb <jhb@FreeBSD.org>2001-03-07 03:21:26 +0000
commit6b93e2c5c0f3e74a1321d45d8e9ccdc24be6c18f (patch)
treeaccb51c95c0edb0a5f54b87feeca5716c815671f /sys/compat/linprocfs
parent83d74ad162604ee6efa77212b10d224fbe60c16a (diff)
downloadFreeBSD-src-6b93e2c5c0f3e74a1321d45d8e9ccdc24be6c18f.zip
FreeBSD-src-6b93e2c5c0f3e74a1321d45d8e9ccdc24be6c18f.tar.gz
Just hold the proc lock while getting the parent's PID rather than a
proctree lock.
Diffstat (limited to 'sys/compat/linprocfs')
-rw-r--r--sys/compat/linprocfs/linprocfs.c15
-rw-r--r--sys/compat/linprocfs/linprocfs_misc.c15
2 files changed, 10 insertions, 20 deletions
diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c
index 8ba6c41..26b1aca 100644
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -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,
diff --git a/sys/compat/linprocfs/linprocfs_misc.c b/sys/compat/linprocfs/linprocfs_misc.c
index 8ba6c41..26b1aca 100644
--- a/sys/compat/linprocfs/linprocfs_misc.c
+++ b/sys/compat/linprocfs/linprocfs_misc.c
@@ -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,
OpenPOWER on IntegriCloud