summaryrefslogtreecommitdiff
path: root/sys/compat/svr4
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2010-07-26 01:56:28 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2010-07-26 01:56:28 +0000
commit12738501a521de949783a0ef772f333a85a28079 (patch)
treea8d79b5579bc5fb4f0fe053219d7da149a912112 /sys/compat/svr4
parent58397ea88d58979fc9e046dc9c64692785b924ae (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/compat/svr4')
-rw-r--r--sys/compat/svr4/svr4_fcntl.c6
-rw-r--r--sys/compat/svr4/svr4_misc.c39
2 files changed, 24 insertions, 21 deletions
diff --git a/sys/compat/svr4/svr4_fcntl.c b/sys/compat/svr4/svr4_fcntl.c
index 02d10d8399a..eb4d927222f 100644
--- a/sys/compat/svr4/svr4_fcntl.c
+++ b/sys/compat/svr4/svr4_fcntl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_fcntl.c,v 1.22 2002/03/14 01:26:51 millert Exp $ */
+/* $OpenBSD: svr4_fcntl.c,v 1.23 2010/07/26 01:56:27 guenther Exp $ */
/* $NetBSD: svr4_fcntl.c,v 1.14 1995/10/14 20:24:24 christos Exp $ */
/*
@@ -338,8 +338,8 @@ svr4_sys_open(p, v, retval)
if (error)
return error;
- if (!(SCARG(&cup, flags) & O_NOCTTY) && SESS_LEADER(p) &&
- !(p->p_flag & P_CONTROLT)) {
+ if (!(SCARG(&cup, flags) & O_NOCTTY) && SESS_LEADER(p->p_p) &&
+ !(p->p_p->ps_flags & PS_CONTROLT)) {
struct filedesc *fdp = p->p_fd;
struct file *fp;
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index f2700bf2d1a..dd2130514a2 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_misc.c,v 1.54 2010/05/25 16:39:15 thib Exp $ */
+/* $OpenBSD: svr4_misc.c,v 1.55 2010/07/26 01:56:27 guenther Exp $ */
/* $NetBSD: svr4_misc.c,v 1.42 1996/12/06 03:22:34 christos Exp $ */
/*
@@ -101,7 +101,7 @@ static void bsd_statfs_to_svr4_statvfs(const struct statfs *,
struct svr4_statvfs *);
static void bsd_statfs_to_svr4_statvfs64(const struct statfs *,
struct svr4_statvfs64 *);
-static struct proc *svr4_pfind(pid_t pid);
+static struct process *svr4_prfind(pid_t pid);
static int svr4_mknod(struct proc *, register_t *, char *,
svr4_mode_t, svr4_dev_t);
@@ -815,20 +815,20 @@ svr4_sys_ulimit(p, v, retval)
}
-static struct proc *
-svr4_pfind(pid)
- pid_t pid;
+static struct process *
+svr4_prfind(pid_t pid)
{
+ struct process *pr;
struct proc *p;
/* look in the live processes */
- if ((p = pfind(pid)) != NULL)
- return p;
+ if ((pr = prfind(pid)) != NULL)
+ return pr;
/* look in the zombies */
LIST_FOREACH(p, &zombproc, p_list)
if (p->p_pid == pid)
- return p;
+ return p->p_flag & P_THREAD ? NULL : p->p_p;
return NULL;
}
@@ -841,11 +841,12 @@ svr4_sys_pgrpsys(p, v, retval)
register_t *retval;
{
struct svr4_sys_pgrpsys_args *uap = v;
+ struct process *pr = p->p_p;
int error;
switch (SCARG(uap, cmd)) {
case 0: /* getpgrp() */
- *retval = p->p_pgrp->pg_id;
+ *retval = pr->ps_pgrp->pg_id;
return 0;
case 1: /* setpgrp() */
@@ -856,19 +857,19 @@ svr4_sys_pgrpsys(p, v, retval)
SCARG(&sa, pgid) = 0;
if ((error = sys_setpgid(p, &sa, retval)) != 0)
return error;
- *retval = p->p_pgrp->pg_id;
+ *retval = pr->ps_pgrp->pg_id;
return 0;
}
case 2: /* getsid(pid) */
if (SCARG(uap, pid) != 0 &&
- (p = svr4_pfind(SCARG(uap, pid))) == NULL)
+ (pr = svr4_prfind(SCARG(uap, pid))) == NULL)
return ESRCH;
/*
* we return the pid of the session leader for this
* process
*/
- *retval = (register_t) p->p_session->s_leader->p_pid;
+ *retval = (register_t)pr->ps_session->s_leader->ps_pid;
return 0;
case 3: /* setsid() */
@@ -877,10 +878,10 @@ svr4_sys_pgrpsys(p, v, retval)
case 4: /* getpgid(pid) */
if (SCARG(uap, pid) != 0 &&
- (p = svr4_pfind(SCARG(uap, pid))) == NULL)
+ (pr = svr4_prfind(SCARG(uap, pid))) == NULL)
return ESRCH;
- *retval = (int) p->p_pgrp->pg_id;
+ *retval = (int)pr->ps_pgrp->pg_id;
return 0;
case 5: /* setpgid(pid, pgid); */
@@ -1042,6 +1043,7 @@ svr4_sys_waitsys(q, v, retval)
struct svr4_sys_waitsys_args *uap = v;
int nfound;
int error;
+ struct process *pr;
struct proc *p;
switch (SCARG(uap, grp)) {
@@ -1049,7 +1051,7 @@ svr4_sys_waitsys(q, v, retval)
break;
case SVR4_P_PGID:
- SCARG(uap, id) = -q->p_pgid;
+ SCARG(uap, id) = -q->p_p->ps_pgid;
break;
case SVR4_P_ALL:
@@ -1065,12 +1067,13 @@ svr4_sys_waitsys(q, v, retval)
loop:
nfound = 0;
- LIST_FOREACH(p, &q->p_children, p_sibling) {
+ LIST_FOREACH(pr, &q->p_p->ps_children, ps_sibling) {
+ p = pr->ps_mainproc;
if (SCARG(uap, id) != WAIT_ANY &&
p->p_pid != SCARG(uap, id) &&
- p->p_pgid != -SCARG(uap, id)) {
+ pr->ps_pgid != -SCARG(uap, id)) {
DPRINTF(("pid %d pgid %d != %d\n", p->p_pid,
- p->p_pgid, SCARG(uap, id)));
+ pr->ps_pgid, SCARG(uap, id)));
continue;
}
nfound++;