summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authortanimura <tanimura@FreeBSD.org>2002-02-23 11:12:57 +0000
committertanimura <tanimura@FreeBSD.org>2002-02-23 11:12:57 +0000
commita09da298590e8c11ebafa37f79e0046814665237 (patch)
tree2289c653c0f7aa23498f82b603c33107952652ec /sys/compat
parent33e8ee5265ca2838260ab581a9cebdedb1e1e29b (diff)
downloadFreeBSD-src-a09da298590e8c11ebafa37f79e0046814665237.zip
FreeBSD-src-a09da298590e8c11ebafa37f79e0046814665237.tar.gz
Lock struct pgrp, session and sigio.
New locks are: - pgrpsess_lock which locks the whole pgrps and sessions, - pg_mtx which protects the pgrp members, and - s_mtx which protects the session members. Please refer to sys/proc.h for the coverage of these locks. Changes on the pgrp/session interface: - pgfind() needs the pgrpsess_lock held. - The caller of enterpgrp() is responsible to allocate a new pgrp and session. - Call enterthispgrp() in order to enter an existing pgrp. - pgsignal() requires a pgrp lock held. Reviewed by: jhb, alfred Tested on: cvsup.jp.FreeBSD.org (which is a quad-CPU machine running -current)
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linprocfs/linprocfs.c2
-rw-r--r--sys/compat/linux/linux_file.c3
-rw-r--r--sys/compat/svr4/svr4_misc.c10
3 files changed, 12 insertions, 3 deletions
diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c
index 06f0f38..ae21891 100644
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -494,9 +494,9 @@ linprocfs_doprocstat(PFS_FILL_ARGS)
PS_ADD("statr", "%c", '0'); /* XXX */
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);
+ PROC_UNLOCK(p);
PS_ADD("tty", "%d", 0); /* XXX */
PS_ADD("tpgid", "%d", 0); /* XXX */
PS_ADD("flags", "%u", 0); /* XXX */
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index 1dfa4a1..dd4f219 100644
--- a/sys/compat/linux/linux_file.c
+++ b/sys/compat/linux/linux_file.c
@@ -144,12 +144,13 @@ linux_open(struct thread *td, struct linux_open_args *args)
fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, td);
fdrop(fp, td);
}
- } else
+ } else {
PROC_UNLOCK(p);
#ifdef DEBUG
if (ldebug(open))
printf(LMSG("open returns error %d"), error);
#endif
+ }
return error;
}
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index 4771d90..9dcfa7f 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -1017,7 +1017,9 @@ svr4_sys_pgrpsys(td, uap)
/*FALLTHROUGH*/
case 0: /* getpgrp() */
+ PROC_LOCK(p);
*retval = p->p_pgrp->pg_id;
+ PROC_UNLOCK(p);
return 0;
case 2: /* getsid(pid) */
@@ -1222,7 +1224,9 @@ svr4_sys_waitsys(td, uap)
break;
case SVR4_P_PGID:
+ PROC_LOCK(td->td_proc);
SCARG(uap, id) = -td->td_proc->p_pgid;
+ PROC_UNLOCK(td->td_proc);
break;
case SVR4_P_ALL:
@@ -1283,8 +1287,12 @@ loop:
if (q->p_oppid != q->p_pptr->p_pid) {
PROC_UNLOCK(q);
t = pfind(q->p_oppid);
+ if (t == NULL) {
+ t = initproc;
+ PROC_LOCK(initproc);
+ }
PROC_LOCK(q);
- proc_reparent(q, t ? t : initproc);
+ proc_reparent(q, t);
q->p_oppid = 0;
q->p_flag &= ~(P_TRACED | P_WAITED);
PROC_UNLOCK(q);
OpenPOWER on IntegriCloud