+tpr_t
+tprintf_open()
+{
+ register struct proc *p = u.u_procp;
+
+ if (p->p_flag & SCTTY && p->p_session->s_ttyvp) {
+ SESSHOLD(p->p_session);
+ return ((tpr_t)p->p_session);
+ } else
+ return ((tpr_t)NULL);
+}
+
+tprintf_close(sess)
+ tpr_t sess;
+{
+ if (sess)
+ SESSRELE(sess);
+}
+
+/*
+ * tprintf prints on the controlling terminal associated
+ * with the given session.
+ */
+/*VARARGS2*/
+tprintf(sess, fmt, x1)
+ register tpr_t sess;
+ char *fmt;
+ unsigned x1;
+{
+ int flags = TOLOG;
+
+ logpri(LOG_INFO);
+
+ if (sess && sess->s_ttyvp && ttycheckoutq(sess->s_ttyp, 0))
+ flags |= TOTTY;
+ prf(fmt, &x1, flags, sess->s_ttyp);
+ logwakeup();
+}
+
+
+/*
+ * Log writes to the log buffer,
+ * and guarantees not to sleep (so can be called by interrupt routines).
+ * If there is no process reading the log yet, it writes to the console also.
+ */
+/*VARARGS2*/
+log(level, fmt, x1)
+ char *fmt;
+ unsigned x1;
+{
+ register s = splhigh();
+ extern int log_open;
+
+ logpri(level);
+ prf(fmt, &x1, TOLOG, (struct tty *)NULL);
+ splx(s);
+ if (!log_open)
+ prf(fmt, &x1, TOCONS, (struct tty *)NULL);
+ logwakeup();
+}
+
+logpri(level)
+ int level;
+{
+
+ putchar('<', TOLOG, (struct tty *)NULL);
+ printn((u_long)level, 10, TOLOG, (struct tty *)NULL);
+ putchar('>', TOLOG, (struct tty *)NULL);
+}
+
+/*VARARGS1*/
+addlog(fmt, x1)
+ char *fmt;
+ unsigned x1;
+{
+ register s = splhigh();