diff options
| author | 2010-07-26 01:56:27 +0000 | |
|---|---|---|
| committer | 2010-07-26 01:56:27 +0000 | |
| commit | 207e4b38a785bf665de26471f4fc5fde67fa99f0 (patch) | |
| tree | 5b61a93df6c22438e6a0955afca220cb2f2207a0 /sys/miscfs/procfs/procfs_status.c | |
| parent | Add missing braces so a loop will function as intended. (diff) | |
| download | wireguard-openbsd-207e4b38a785bf665de26471f4fc5fde67fa99f0.tar.xz wireguard-openbsd-207e4b38a785bf665de26471f4fc5fde67fa99f0.zip | |
Correct the links between threads, processes, pgrps, and sessions,
so that the process-level stuff is to/from struct process and not
struct proc. This fixes a bunch of problem cases in rthreads.
Based on earlier work by blambert and myself, but mostly written
at c2k10.
Tested by many: deraadt, sthen, krw, ray, and in snapshots
Diffstat (limited to 'sys/miscfs/procfs/procfs_status.c')
| -rw-r--r-- | sys/miscfs/procfs/procfs_status.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/sys/miscfs/procfs/procfs_status.c b/sys/miscfs/procfs/procfs_status.c index 0a6fbb47fff..0a629e92a04 100644 --- a/sys/miscfs/procfs/procfs_status.c +++ b/sys/miscfs/procfs/procfs_status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procfs_status.c,v 1.10 2007/06/18 08:30:07 jasper Exp $ */ +/* $OpenBSD: procfs_status.c,v 1.11 2010/07/26 01:56:27 guenther Exp $ */ /* $NetBSD: procfs_status.c,v 1.11 1996/03/16 23:52:50 christos Exp $ */ /* @@ -64,6 +64,7 @@ int procfs_stat_gen(struct proc *, char *s, int); int procfs_stat_gen(struct proc *p, char *s, int l) { + struct process *pr = p->p_p; struct session *sess; struct tty *tp; struct ucred *cr; @@ -72,11 +73,11 @@ procfs_stat_gen(struct proc *p, char *s, int l) char ps[256], *sep; int i, n; - pid = p->p_pid; - ppid = p->p_pptr ? p->p_pptr->p_pid : 0; - pgid = p->p_pgrp->pg_id; - sess = p->p_pgrp->pg_session; - sid = sess->s_leader ? sess->s_leader->p_pid : 0; + pid = pr->ps_pid; + ppid = pr->ps_pptr ? pr->ps_pptr->ps_pid : 0; + pgid = pr->ps_pgrp->pg_id; + sess = pr->ps_pgrp->pg_session; + sid = sess->s_leader ? sess->s_leader->ps_pid : 0; n = 0; if (s) @@ -90,7 +91,7 @@ procfs_stat_gen(struct proc *p, char *s, int l) pid, ppid, pgid, sid); COUNTORCAT(s, l, ps, n); - if ((p->p_flag&P_CONTROLT) && (tp = sess->s_ttyp)) + if ((pr->ps_flags & PS_CONTROLT) && (tp = sess->s_ttyp)) snprintf(ps, sizeof(ps), "%d,%d ", major(tp->t_dev), minor(tp->t_dev)); else @@ -105,7 +106,7 @@ procfs_stat_gen(struct proc *p, char *s, int l) COUNTORCAT(s, l, ps, n); } - if (SESS_LEADER(p)) { + if (SESS_LEADER(pr)) { snprintf(ps, sizeof(ps), "%ssldr", sep); sep = ","; COUNTORCAT(s, l, ps, n); |
