Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_prf.c
Show First 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | uprintf(const char *fmt, ...) | ||||
struct proc *p; | struct proc *p; | ||||
struct thread *td; | struct thread *td; | ||||
int retval; | int retval; | ||||
td = curthread; | td = curthread; | ||||
if (TD_IS_IDLETHREAD(td)) | if (TD_IS_IDLETHREAD(td)) | ||||
return (0); | return (0); | ||||
sx_slock(&proctree_lock); | sx_slock(&V_proctree_lock); | ||||
p = td->td_proc; | p = td->td_proc; | ||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
if ((p->p_flag & P_CONTROLT) == 0) { | if ((p->p_flag & P_CONTROLT) == 0) { | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
sx_sunlock(&proctree_lock); | sx_sunlock(&V_proctree_lock); | ||||
return (0); | return (0); | ||||
} | } | ||||
SESS_LOCK(p->p_session); | SESS_LOCK(p->p_session); | ||||
pca.tty = p->p_session->s_ttyp; | pca.tty = p->p_session->s_ttyp; | ||||
SESS_UNLOCK(p->p_session); | SESS_UNLOCK(p->p_session); | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
if (pca.tty == NULL) { | if (pca.tty == NULL) { | ||||
sx_sunlock(&proctree_lock); | sx_sunlock(&V_proctree_lock); | ||||
return (0); | return (0); | ||||
} | } | ||||
pca.flags = TOTTY; | pca.flags = TOTTY; | ||||
pca.p_bufr = NULL; | pca.p_bufr = NULL; | ||||
va_start(ap, fmt); | va_start(ap, fmt); | ||||
tty_lock(pca.tty); | tty_lock(pca.tty); | ||||
sx_sunlock(&proctree_lock); | sx_sunlock(&V_proctree_lock); | ||||
retval = kvprintf(fmt, putchar, &pca, 10, ap); | retval = kvprintf(fmt, putchar, &pca, 10, ap); | ||||
tty_unlock(pca.tty); | tty_unlock(pca.tty); | ||||
va_end(ap); | va_end(ap); | ||||
return (retval); | return (retval); | ||||
} | } | ||||
/* | /* | ||||
* tprintf and vtprintf print on the controlling terminal associated with the | * tprintf and vtprintf print on the controlling terminal associated with the | ||||
Show All 12 Lines | |||||
void | void | ||||
vtprintf(struct proc *p, int pri, const char *fmt, va_list ap) | vtprintf(struct proc *p, int pri, const char *fmt, va_list ap) | ||||
{ | { | ||||
struct tty *tp = NULL; | struct tty *tp = NULL; | ||||
int flags = 0; | int flags = 0; | ||||
struct putchar_arg pca; | struct putchar_arg pca; | ||||
struct session *sess = NULL; | struct session *sess = NULL; | ||||
sx_slock(&proctree_lock); | sx_slock(&V_proctree_lock); | ||||
if (pri != -1) | if (pri != -1) | ||||
flags |= TOLOG; | flags |= TOLOG; | ||||
if (p != NULL) { | if (p != NULL) { | ||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) { | if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) { | ||||
sess = p->p_session; | sess = p->p_session; | ||||
sess_hold(sess); | sess_hold(sess); | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
tp = sess->s_ttyp; | tp = sess->s_ttyp; | ||||
if (tp != NULL && tty_checkoutq(tp)) | if (tp != NULL && tty_checkoutq(tp)) | ||||
flags |= TOTTY; | flags |= TOTTY; | ||||
else | else | ||||
tp = NULL; | tp = NULL; | ||||
} else | } else | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
} | } | ||||
pca.pri = pri; | pca.pri = pri; | ||||
pca.tty = tp; | pca.tty = tp; | ||||
pca.flags = flags; | pca.flags = flags; | ||||
pca.p_bufr = NULL; | pca.p_bufr = NULL; | ||||
if (pca.tty != NULL) | if (pca.tty != NULL) | ||||
tty_lock(pca.tty); | tty_lock(pca.tty); | ||||
sx_sunlock(&proctree_lock); | sx_sunlock(&V_proctree_lock); | ||||
kvprintf(fmt, putchar, &pca, 10, ap); | kvprintf(fmt, putchar, &pca, 10, ap); | ||||
if (pca.tty != NULL) | if (pca.tty != NULL) | ||||
tty_unlock(pca.tty); | tty_unlock(pca.tty); | ||||
if (sess != NULL) | if (sess != NULL) | ||||
sess_release(sess); | sess_release(sess); | ||||
msgbuftrigger = 1; | msgbuftrigger = 1; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,015 Lines • Show Last 20 Lines |