summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 6cc7be2..79441ba 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -36,6 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.c 8.8 (Berkeley) 1/21/94
+ * $Id: tty.c,v 1.5 1994/08/02 07:42:46 davidg Exp $
*/
#include <sys/param.h>
@@ -69,6 +70,10 @@ char ttybuf[] = "ttybuf";
char ttyin[] = "ttyin";
char ttyout[] = "ttyout";
+#ifndef CBLOCKS_PER_TTY
+#define CBLOCKS_PER_TTY 10
+#endif
+
/*
* Table with character classes and parity. The 8th bit indicates parity,
* the 7th bit indicates the character is an alphameric or underscore (for
@@ -162,6 +167,10 @@ ttyopen(device, tp)
if (!ISSET(tp->t_state, TS_ISOPEN)) {
SET(tp->t_state, TS_ISOPEN);
bzero(&tp->t_winsize, sizeof(tp->t_winsize));
+ /*
+ * Add some cblocks to the clistfree pool.
+ */
+ cblock_alloc_cblocks(CBLOCKS_PER_TTY);
}
CLR(tp->t_state, TS_WOPEN);
splx(s);
@@ -187,6 +196,13 @@ ttyclose(tp)
tp->t_gen++;
tp->t_pgrp = NULL;
tp->t_session = NULL;
+ /*
+ * If the tty has not already been closed, free the cblocks
+ * that were allocated in ttyopen() back to the system malloc
+ * pool.
+ */
+ if (ISSET(tp->t_state, (TS_ISOPEN|TS_WOPEN)))
+ cblock_free_cblocks(CBLOCKS_PER_TTY);
tp->t_state = 0;
return (0);
}
@@ -633,6 +649,7 @@ ttioctl(tp, cmd, data, flag)
#ifdef notdef
case TIOCSPGRP:
#endif
+ case TIOCSTAT:
case TIOCSTI:
case TIOCSWINSZ:
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
@@ -871,6 +888,9 @@ ttioctl(tp, cmd, data, flag)
tp->t_pgrp = pgrp;
break;
}
+ case TIOCSTAT: /* simulate control-T */
+ ttyinfo(tp);
+ break;
case TIOCSWINSZ: /* set window size */
if (bcmp((caddr_t)&tp->t_winsize, data,
sizeof (struct winsize))) {
@@ -1355,7 +1375,7 @@ ttwrite(tp, uio, flag)
register struct uio *uio;
int flag;
{
- register char *cp;
+ register char *cp = 0;
register int cc, ce;
register struct proc *p;
int i, hiwat, cnt, error, s;
@@ -1516,8 +1536,10 @@ ovhiwat:
uio->uio_resid += cc;
return (uio->uio_resid == cnt ? EWOULDBLOCK : 0);
}
- SET(tp->t_state, TS_ASLEEP);
- error = ttysleep(tp, &tp->t_outq, TTOPRI | PCATCH, ttyout, 0);
+ if (tp->t_outq.c_cc || ISSET(tp->t_state, TS_BUSY)) {
+ SET(tp->t_state, TS_ASLEEP);
+ error = ttysleep(tp, &tp->t_outq, TTOPRI | PCATCH, ttyout, 0);
+ }
splx(s);
if (error)
goto out;
OpenPOWER on IntegriCloud