diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2010-07-26 01:56:28 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2010-07-26 01:56:28 +0000 |
commit | 12738501a521de949783a0ef772f333a85a28079 (patch) | |
tree | a8d79b5579bc5fb4f0fe053219d7da149a912112 /sys/miscfs | |
parent | 58397ea88d58979fc9e046dc9c64692785b924ae (diff) |
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')
-rw-r--r-- | sys/miscfs/procfs/procfs_ctl.c | 22 | ||||
-rw-r--r-- | sys/miscfs/procfs/procfs_status.c | 17 | ||||
-rw-r--r-- | sys/miscfs/specfs/spec_vnops.c | 6 |
3 files changed, 23 insertions, 22 deletions
diff --git a/sys/miscfs/procfs/procfs_ctl.c b/sys/miscfs/procfs/procfs_ctl.c index b2d5a1ce74c..0fed64e4fc6 100644 --- a/sys/miscfs/procfs/procfs_ctl.c +++ b/sys/miscfs/procfs/procfs_ctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procfs_ctl.c,v 1.21 2007/06/18 08:30:07 jasper Exp $ */ +/* $OpenBSD: procfs_ctl.c,v 1.22 2010/07/26 01:56:27 guenther Exp $ */ /* $NetBSD: procfs_ctl.c,v 1.14 1996/02/09 22:40:48 christos Exp $ */ /* @@ -57,7 +57,7 @@ */ #define TRACE_WAIT_P(curp, p) \ ((p)->p_stat == SSTOP && \ - (p)->p_pptr == (curp) && \ + (p)->p_p->ps_pptr == (curp)->p_p && \ ISSET((p)->p_flag, P_TRACED)) #ifdef PTRACE @@ -137,9 +137,9 @@ procfs_control(struct proc *curp, struct proc *p, int op) */ atomic_setbits_int(&p->p_flag, P_TRACED); p->p_xstat = 0; /* XXX ? */ - if (p->p_pptr != curp) { - p->p_oppid = p->p_pptr->p_pid; - proc_reparent(p, curp); + if (p->p_p->ps_pptr != curp->p_p) { + p->p_oppid = p->p_p->ps_pptr->ps_pid; + proc_reparent(p->p_p, curp->p_p); } psignal(p, SIGSTOP); return (0); @@ -187,12 +187,12 @@ procfs_control(struct proc *curp, struct proc *p, int op) atomic_clearbits_int(&p->p_flag, P_TRACED); /* give process back to original parent */ - if (p->p_oppid != p->p_pptr->p_pid) { - struct proc *pp; + if (p->p_oppid != p->p_p->ps_pptr->ps_pid) { + struct process *ppr; - pp = pfind(p->p_oppid); - if (pp) - proc_reparent(p, pp); + ppr = prfind(p->p_oppid); + if (ppr) + proc_reparent(p->p_p, ppr); } p->p_oppid = 0; @@ -232,7 +232,7 @@ procfs_control(struct proc *curp, struct proc *p, int op) while (error == 0 && (p->p_stat != SSTOP) && ISSET(p->p_flag, P_TRACED) && - (p->p_pptr == curp)) { + (p->p_p->ps_pptr == curp->p_p)) { error = tsleep(p, PWAIT|PCATCH, "procfsx", 0); } if (error == 0 && !TRACE_WAIT_P(curp, p)) 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); diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c index c1816c58186..11fde4c819b 100644 --- a/sys/miscfs/specfs/spec_vnops.c +++ b/sys/miscfs/specfs/spec_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spec_vnops.c,v 1.57 2010/05/18 04:41:14 dlg Exp $ */ +/* $OpenBSD: spec_vnops.c,v 1.58 2010/07/26 01:56:27 guenther Exp $ */ /* $NetBSD: spec_vnops.c,v 1.29 1996/04/22 01:42:38 christos Exp $ */ /* @@ -500,9 +500,9 @@ spec_close(void *v) * plus the session), release the reference from the session. */ if (vcount(vp) == 2 && ap->a_p && - vp == ap->a_p->p_session->s_ttyvp) { + vp == ap->a_p->p_p->ps_session->s_ttyvp) { vrele(vp); - ap->a_p->p_session->s_ttyvp = NULL; + ap->a_p->p_p->ps_session->s_ttyvp = NULL; } if (cdevsw[major(dev)].d_flags & D_CLONE) return (spec_close_clone(ap)); |