39c39
< * $FreeBSD: head/sys/kern/subr_prf.c 90490 2002-02-10 22:04:44Z phk $
---
> * $FreeBSD: head/sys/kern/subr_prf.c 91140 2002-02-23 11:12:57Z tanimura $
43a44,46
> #include <sys/lock.h>
> #include <sys/mutex.h>
> #include <sys/sx.h>
116c119
< int retval = 0;
---
> int retval;
118,124c121,128
< if (td && td != PCPU_GET(idlethread) && p->p_flag & P_CONTROLT &&
< p->p_session->s_ttyvp) {
< va_start(ap, fmt);
< pca.tty = p->p_session->s_ttyp;
< pca.flags = TOTTY;
< retval = kvprintf(fmt, putchar, &pca, 10, ap);
< va_end(ap);
---
> if (td == NULL || td == PCPU_GET(idlethread))
> return (0);
>
> p = td->td_proc;
> PROC_LOCK(p);
> if ((p->p_flag & P_CONTROLT) == 0) {
> PROC_UNLOCK(p);
> return (0);
125a130,140
> SESS_LOCK(p->p_session);
> pca.tty = p->p_session->s_ttyp;
> SESS_UNLOCK(p->p_session);
> PROC_UNLOCK(p);
> if (pca.tty == NULL)
> return (0);
> pca.flags = TOTTY;
> va_start(ap, fmt);
> retval = kvprintf(fmt, putchar, &pca, 10, ap);
> va_end(ap);
>
144,148c159,164
< if (p && p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) {
< SESSHOLD(p->p_session);
< shld++;
< if (ttycheckoutq(p->p_session->s_ttyp, 0)) {
< flags |= TOTTY;
---
> if (p != NULL) {
> PGRPSESS_XLOCK();
> PROC_LOCK(p);
> if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) {
> SESS_LOCK(p->p_session);
> SESSHOLD(p->p_session);
150c166,175
< }
---
> SESS_UNLOCK(p->p_session);
> PROC_UNLOCK(p);
> shld++;
> if (ttycheckoutq(tp, 0))
> flags |= TOTTY;
> else
> tp = NULL;
> } else
> PROC_UNLOCK(p);
> PGRPSESS_XUNLOCK();
158c183,185
< if (shld)
---
> if (shld) {
> PGRPSESS_XLOCK();
> SESS_LOCK(p->p_session);
159a187,189
> SESS_UNLOCK(p->p_session);
> PGRPSESS_XUNLOCK();
> }
< * $FreeBSD: head/sys/kern/subr_prf.c 90490 2002-02-10 22:04:44Z phk $
---
> * $FreeBSD: head/sys/kern/subr_prf.c 91140 2002-02-23 11:12:57Z tanimura $
43a44,46
> #include <sys/lock.h>
> #include <sys/mutex.h>
> #include <sys/sx.h>
116c119
< int retval = 0;
---
> int retval;
118,124c121,128
< if (td && td != PCPU_GET(idlethread) && p->p_flag & P_CONTROLT &&
< p->p_session->s_ttyvp) {
< va_start(ap, fmt);
< pca.tty = p->p_session->s_ttyp;
< pca.flags = TOTTY;
< retval = kvprintf(fmt, putchar, &pca, 10, ap);
< va_end(ap);
---
> if (td == NULL || td == PCPU_GET(idlethread))
> return (0);
>
> p = td->td_proc;
> PROC_LOCK(p);
> if ((p->p_flag & P_CONTROLT) == 0) {
> PROC_UNLOCK(p);
> return (0);
125a130,140
> SESS_LOCK(p->p_session);
> pca.tty = p->p_session->s_ttyp;
> SESS_UNLOCK(p->p_session);
> PROC_UNLOCK(p);
> if (pca.tty == NULL)
> return (0);
> pca.flags = TOTTY;
> va_start(ap, fmt);
> retval = kvprintf(fmt, putchar, &pca, 10, ap);
> va_end(ap);
>
144,148c159,164
< if (p && p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) {
< SESSHOLD(p->p_session);
< shld++;
< if (ttycheckoutq(p->p_session->s_ttyp, 0)) {
< flags |= TOTTY;
---
> if (p != NULL) {
> PGRPSESS_XLOCK();
> PROC_LOCK(p);
> if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) {
> SESS_LOCK(p->p_session);
> SESSHOLD(p->p_session);
150c166,175
< }
---
> SESS_UNLOCK(p->p_session);
> PROC_UNLOCK(p);
> shld++;
> if (ttycheckoutq(tp, 0))
> flags |= TOTTY;
> else
> tp = NULL;
> } else
> PROC_UNLOCK(p);
> PGRPSESS_XUNLOCK();
158c183,185
< if (shld)
---
> if (shld) {
> PGRPSESS_XLOCK();
> SESS_LOCK(p->p_session);
159a187,189
> SESS_UNLOCK(p->p_session);
> PGRPSESS_XUNLOCK();
> }