Use SESSHOLD and SESSRELE consistently.
Add SESSHOLD and SESSRELE to the t_session, so that we don't have dangling references [inspired by OpenBSD].
This commit is contained in:
parent
f49045ad2d
commit
7d930e8572
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_proc.c,v 1.46 2002/03/08 20:48:40 thorpej Exp $ */
|
||||
/* $NetBSD: kern_proc.c,v 1.47 2002/04/12 17:02:33 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
|
@ -73,7 +73,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.46 2002/03/08 20:48:40 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.47 2002/04/12 17:02:33 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -393,8 +393,8 @@ enterpgrp(p, pgid, mksess)
|
|||
panic("enterpgrp: mksession and p != curproc");
|
||||
#endif
|
||||
} else {
|
||||
SESSHOLD(p->p_session);
|
||||
pgrp->pg_session = p->p_session;
|
||||
pgrp->pg_session->s_count++;
|
||||
}
|
||||
pgrp->pg_id = pgid;
|
||||
LIST_INIT(&pgrp->pg_members);
|
||||
|
@ -447,12 +447,7 @@ pgdelete(pgrp)
|
|||
pgrp->pg_session->s_ttyp->t_pgrp == pgrp)
|
||||
pgrp->pg_session->s_ttyp->t_pgrp = NULL;
|
||||
LIST_REMOVE(pgrp, pg_hash);
|
||||
if (--pgrp->pg_session->s_count == 0) {
|
||||
/* Remove reference (if any) from tty to this session */
|
||||
if (pgrp->pg_session->s_ttyp != NULL)
|
||||
pgrp->pg_session->s_ttyp->t_session = NULL;
|
||||
FREE(pgrp->pg_session, M_SESSION);
|
||||
}
|
||||
SESSRELE(pgrp->pg_session);
|
||||
pool_put(&pgrp_pool, pgrp);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tty.c,v 1.135 2002/03/25 04:26:43 itohy Exp $ */
|
||||
/* $NetBSD: tty.c,v 1.136 2002/04/12 17:02:33 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1990, 1991, 1993
|
||||
|
@ -41,7 +41,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.135 2002/03/25 04:26:43 itohy Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.136 2002/04/12 17:02:33 christos Exp $");
|
||||
|
||||
#include "opt_uconsole.h"
|
||||
|
||||
|
@ -267,7 +267,10 @@ ttyclose(struct tty *tp)
|
|||
|
||||
tp->t_gen++;
|
||||
tp->t_pgrp = NULL;
|
||||
if (tp->t_session != NULL) {
|
||||
SESSRELE(tp->t_session);
|
||||
tp->t_session = NULL;
|
||||
}
|
||||
tp->t_state = 0;
|
||||
return (0);
|
||||
}
|
||||
|
@ -988,6 +991,7 @@ ttioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p)
|
|||
((p->p_session->s_ttyvp || tp->t_session) &&
|
||||
(tp->t_session != p->p_session)))
|
||||
return (EPERM);
|
||||
SESSHOLD(p->p_session);
|
||||
tp->t_session = p->p_session;
|
||||
tp->t_pgrp = p->p_pgrp;
|
||||
p->p_session->s_ttyp = tp;
|
||||
|
|
Loading…
Reference in New Issue