+
+/*
+ * (^T)
+ * Report on state of foreground process group.
+ */
+ttyinfo(tp)
+ struct tty *tp;
+{
+ register struct proc *p;
+
+ if (ttycheckoutq(tp,0) == 0)
+ return;
+ if (tp->t_session == NULL)
+ ttyprintf(tp, "kernel: not a controlling terminal\n");
+ else if (tp->t_pgrp == NULL ||
+ (p = tp->t_pgrp->pg_mem) == NULL)
+ ttyprintf(tp, "kernel: no foreground process group\n");
+ else {
+ int i = 0;
+
+ for (; p != NULL; p = p->p_pgrpnxt) {
+ ttyprintf(tp,
+ "kernel: pid: %d state: %x wchan: %x ticks: %d\n",
+ p->p_pid, p->p_stat, p->p_wchan, p->p_cpticks);
+ if (++i > 6) {
+ ttyprintf(tp, "kernel: more...\n");
+ break;
+ }
+ }
+ }
+}
+
+#define TOTTY 0x2 /* XXX should be in header */
+/*VARARGS2*/
+ttyprintf(tp, fmt, x1)
+ struct tty *tp;
+ char *fmt;
+ unsigned x1;
+{
+ prf(fmt, &x1, TOTTY, (caddr_t)tp);
+}
+
+/*
+ * Output char to tty; console putchar style.
+ */
+tputchar(c, tp)
+ int c;
+ struct tty *tp;
+{
+ register s = spltty();
+
+ if ((tp->t_state & (TS_CARR_ON | TS_ISOPEN))
+ == (TS_CARR_ON | TS_ISOPEN)) {
+ if (c == '\n')
+ (void) ttyoutput('\r', tp);
+ (void) ttyoutput(c, tp);
+ ttstart(tp);
+ splx(s);
+ return (0);
+ }
+ splx(s);
+ return (-1);
+}