summaryrefslogtreecommitdiffstats
path: root/sys/pc98
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-04-24 00:51:53 +0000
committerjhb <jhb@FreeBSD.org>2001-04-24 00:51:53 +0000
commit9c03a8ae91e06e47f0c59996ef0e2300e231e101 (patch)
treeec00c764b1eb58ed4297070edb5806ffd7ca4765 /sys/pc98
parent383dd0a2656889604bb7eb71b993875024ddd832 (diff)
downloadFreeBSD-src-9c03a8ae91e06e47f0c59996ef0e2300e231e101.zip
FreeBSD-src-9c03a8ae91e06e47f0c59996ef0e2300e231e101.tar.gz
Change the pfind() and zpfind() functions to lock the process that they
find before releasing the allproc lock and returning. Reviewed by: -smp, dfr, jake
Diffstat (limited to 'sys/pc98')
-rw-r--r--sys/pc98/pc98/syscons.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/sys/pc98/pc98/syscons.c b/sys/pc98/pc98/syscons.c
index 54c51dc..a5f73d6 100644
--- a/sys/pc98/pc98/syscons.c
+++ b/sys/pc98/pc98/syscons.c
@@ -841,14 +841,20 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
case VT_SETMODE: /* set screen switcher mode */
{
struct vt_mode *mode;
+ struct proc *p1;
mode = (struct vt_mode *)data;
DPRINTF(5, ("sc%d: VT_SETMODE ", sc->unit));
if (scp->smode.mode == VT_PROCESS) {
- if (scp->proc == pfind(scp->pid) && scp->proc != p) {
+ p1 = pfind(scp->pid);
+ if (scp->proc == p1 && scp->proc != p) {
+ if (p1)
+ PROC_UNLOCK(p1);
DPRINTF(5, ("error EPERM\n"));
return EPERM;
}
+ if (p1)
+ PROC_UNLOCK(p1);
}
s = spltty();
if (mode->mode == VT_AUTO) {
@@ -2081,6 +2087,7 @@ int
sc_switch_scr(sc_softc_t *sc, u_int next_scr)
{
struct tty *tp;
+ struct proc *p;
int s;
DPRINTF(5, ("sc0: sc_switch_scr() %d ", next_scr + 1));
@@ -2100,7 +2107,10 @@ sc_switch_scr(sc_softc_t *sc, u_int next_scr)
if (sc->switch_in_progress
&& (sc->cur_scp->smode.mode == VT_PROCESS)
&& sc->cur_scp->proc) {
- if (sc->cur_scp->proc != pfind(sc->cur_scp->pid)) {
+ p = pfind(sc->cur_scp->pid);
+ if (sc->cur_scp->proc != p) {
+ if (p)
+ PROC_UNLOCK(p);
/*
* The controlling process has died!!. Do some clean up.
* NOTE:`cur_scp->proc' and `cur_scp->smode.mode'
@@ -2133,6 +2143,8 @@ sc_switch_scr(sc_softc_t *sc, u_int next_scr)
DPRINTF(5, ("waiting nothing, "));
}
} else {
+ if (p)
+ PROC_UNLOCK(p);
/*
* The controlling process is alive, but not responding...
* It is either buggy or it may be just taking time.
@@ -2297,8 +2309,12 @@ do_switch_scr(sc_softc_t *sc, int s)
static int
vt_proc_alive(scr_stat *scp)
{
+ struct proc *p;
+
if (scp->proc) {
- if (scp->proc == pfind(scp->pid))
+ if ((p = pfind(scp->pid)) != NULL)
+ PROC_UNLOCK(p);
+ if (scp->proc == p)
return TRUE;
scp->proc = NULL;
scp->smode.mode = VT_AUTO;
OpenPOWER on IntegriCloud