Deleted Added
full compact
tty.c (2106) tty.c (3308)
1/*-
2 * Copyright (c) 1982, 1986, 1990, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)tty.c 8.8 (Berkeley) 1/21/94
1/*-
2 * Copyright (c) 1982, 1986, 1990, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)tty.c 8.8 (Berkeley) 1/21/94
39 * $Id: tty.c,v 1.5 1994/08/02 07:42:46 davidg Exp $
39 * $Id: tty.c,v 1.6 1994/08/18 09:16:21 davidg Exp $
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/ioctl.h>
45#include <sys/proc.h>
46#define TTYDEFCHARS
47#include <sys/tty.h>
48#undef TTYDEFCHARS
49#include <sys/file.h>
50#include <sys/conf.h>
51#include <sys/dkstat.h>
52#include <sys/uio.h>
53#include <sys/kernel.h>
54#include <sys/vnode.h>
55#include <sys/syslog.h>
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/ioctl.h>
45#include <sys/proc.h>
46#define TTYDEFCHARS
47#include <sys/tty.h>
48#undef TTYDEFCHARS
49#include <sys/file.h>
50#include <sys/conf.h>
51#include <sys/dkstat.h>
52#include <sys/uio.h>
53#include <sys/kernel.h>
54#include <sys/vnode.h>
55#include <sys/syslog.h>
56#include <sys/signalvar.h>
57#include <sys/resourcevar.h>
56
57#include <vm/vm.h>
58
59static int proc_compare __P((struct proc *p1, struct proc *p2));
60static int ttnread __P((struct tty *));
61static void ttyblock __P((struct tty *tp));
62static void ttyecho __P((int, struct tty *tp));
63static void ttyrubo __P((struct tty *, int));

--- 145 unchanged lines hidden (view full) ---

209
210#define FLUSHQ(q) { \
211 if ((q)->c_cc) \
212 ndflush(q, (q)->c_cc); \
213}
214
215/* Is 'c' a line delimiter ("break" character)? */
216#define TTBREAKC(c) \
58
59#include <vm/vm.h>
60
61static int proc_compare __P((struct proc *p1, struct proc *p2));
62static int ttnread __P((struct tty *));
63static void ttyblock __P((struct tty *tp));
64static void ttyecho __P((int, struct tty *tp));
65static void ttyrubo __P((struct tty *, int));

--- 145 unchanged lines hidden (view full) ---

211
212#define FLUSHQ(q) { \
213 if ((q)->c_cc) \
214 ndflush(q, (q)->c_cc); \
215}
216
217/* Is 'c' a line delimiter ("break" character)? */
218#define TTBREAKC(c) \
217 ((c) == '\n' || ((c) == cc[VEOF] || \
218 (c) == cc[VEOL] || (c) == cc[VEOL2]) && (c) != _POSIX_VDISABLE)
219 ((c) == '\n' || (((c) == cc[VEOF] || \
220 (c) == cc[VEOL] || (c) == cc[VEOL2]) && (c) != _POSIX_VDISABLE))
219
220
221/*
222 * Process input of a single character received on a tty.
223 */
224int
225ttyinput(c, tp)
226 register int c;

--- 19 unchanged lines hidden (view full) ---

246 ++tk_rawcc;
247 ++tp->t_rawcc;
248 }
249 ++tk_nin;
250
251 /* Handle exceptional conditions (break, parity, framing). */
252 cc = tp->t_cc;
253 iflag = tp->t_iflag;
221
222
223/*
224 * Process input of a single character received on a tty.
225 */
226int
227ttyinput(c, tp)
228 register int c;

--- 19 unchanged lines hidden (view full) ---

248 ++tk_rawcc;
249 ++tp->t_rawcc;
250 }
251 ++tk_nin;
252
253 /* Handle exceptional conditions (break, parity, framing). */
254 cc = tp->t_cc;
255 iflag = tp->t_iflag;
254 if (err = (ISSET(c, TTY_ERRORMASK))) {
256 err = (ISSET(c, TTY_ERRORMASK));
257 if (err) {
255 CLR(c, TTY_ERRORMASK);
256 if (ISSET(err, TTY_FE) && !c) { /* Break. */
257 if (ISSET(iflag, IGNBRK))
258 goto endcase;
259 else if (ISSET(iflag, BRKINT) &&
260 ISSET(lflag, ISIG) &&
261 (cc[VINTR] != _POSIX_VDISABLE))
262 c = cc[VINTR];
263 else if (ISSET(iflag, PARMRK))
264 goto parmrk;
258 CLR(c, TTY_ERRORMASK);
259 if (ISSET(err, TTY_FE) && !c) { /* Break. */
260 if (ISSET(iflag, IGNBRK))
261 goto endcase;
262 else if (ISSET(iflag, BRKINT) &&
263 ISSET(lflag, ISIG) &&
264 (cc[VINTR] != _POSIX_VDISABLE))
265 c = cc[VINTR];
266 else if (ISSET(iflag, PARMRK))
267 goto parmrk;
265 } else if (ISSET(err, TTY_PE) &&
266 ISSET(iflag, INPCK) || ISSET(err, TTY_FE)) {
268 } else if ((ISSET(err, TTY_PE) && ISSET(iflag, INPCK))
269 || ISSET(err, TTY_FE)) {
267 if (ISSET(iflag, IGNPAR))
268 goto endcase;
269 else if (ISSET(iflag, PARMRK)) {
270parmrk: (void)putc(0377 | TTY_QUOTE, &tp->t_rawq);
271 (void)putc(0 | TTY_QUOTE, &tp->t_rawq);
272 (void)putc(c | TTY_QUOTE, &tp->t_rawq);
273 goto endcase;
274 } else

--- 387 unchanged lines hidden (view full) ---

662 case TIOCSETP:
663 case TIOCSLTC:
664#endif
665 while (isbackground(curproc, tp) &&
666 p->p_pgrp->pg_jobc && (p->p_flag & P_PPWAIT) == 0 &&
667 (p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
668 (p->p_sigmask & sigmask(SIGTTOU)) == 0) {
669 pgsignal(p->p_pgrp, SIGTTOU, 1);
270 if (ISSET(iflag, IGNPAR))
271 goto endcase;
272 else if (ISSET(iflag, PARMRK)) {
273parmrk: (void)putc(0377 | TTY_QUOTE, &tp->t_rawq);
274 (void)putc(0 | TTY_QUOTE, &tp->t_rawq);
275 (void)putc(c | TTY_QUOTE, &tp->t_rawq);
276 goto endcase;
277 } else

--- 387 unchanged lines hidden (view full) ---

665 case TIOCSETP:
666 case TIOCSLTC:
667#endif
668 while (isbackground(curproc, tp) &&
669 p->p_pgrp->pg_jobc && (p->p_flag & P_PPWAIT) == 0 &&
670 (p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
671 (p->p_sigmask & sigmask(SIGTTOU)) == 0) {
672 pgsignal(p->p_pgrp, SIGTTOU, 1);
670 if (error = ttysleep(tp,
671 &lbolt, TTOPRI | PCATCH, ttybg, 0))
673 error = ttysleep(tp, &lbolt, TTOPRI | PCATCH, ttybg, 0);
674 if (error)
672 return (error);
673 }
674 break;
675 }
676
677 switch (cmd) { /* Process the ioctl. */
678 case FIOASYNC: /* set/clear async i/o */
679 s = spltty();

--- 33 unchanged lines hidden (view full) ---

713 if (error = suser(p->p_ucred, &p->p_acflag))
714 return (error);
715#endif
716 constty = tp;
717 } else if (tp == constty)
718 constty = NULL;
719 break;
720 case TIOCDRAIN: /* wait till output drained */
675 return (error);
676 }
677 break;
678 }
679
680 switch (cmd) { /* Process the ioctl. */
681 case FIOASYNC: /* set/clear async i/o */
682 s = spltty();

--- 33 unchanged lines hidden (view full) ---

716 if (error = suser(p->p_ucred, &p->p_acflag))
717 return (error);
718#endif
719 constty = tp;
720 } else if (tp == constty)
721 constty = NULL;
722 break;
723 case TIOCDRAIN: /* wait till output drained */
721 if (error = ttywait(tp))
724 error = ttywait(tp);
725 if (error)
722 return (error);
723 break;
724 case TIOCGETA: { /* get termios struct */
725 struct termios *t = (struct termios *)data;
726
727 bcopy(&tp->t_termios, t, sizeof(struct termios));
728 break;
729 }

--- 25 unchanged lines hidden (view full) ---

755 break;
756 case TIOCSETA: /* set termios struct */
757 case TIOCSETAW: /* drain output, set */
758 case TIOCSETAF: { /* drn out, fls in, set */
759 register struct termios *t = (struct termios *)data;
760
761 s = spltty();
762 if (cmd == TIOCSETAW || cmd == TIOCSETAF) {
726 return (error);
727 break;
728 case TIOCGETA: { /* get termios struct */
729 struct termios *t = (struct termios *)data;
730
731 bcopy(&tp->t_termios, t, sizeof(struct termios));
732 break;
733 }

--- 25 unchanged lines hidden (view full) ---

759 break;
760 case TIOCSETA: /* set termios struct */
761 case TIOCSETAW: /* drain output, set */
762 case TIOCSETAF: { /* drn out, fls in, set */
763 register struct termios *t = (struct termios *)data;
764
765 s = spltty();
766 if (cmd == TIOCSETAW || cmd == TIOCSETAF) {
763 if (error = ttywait(tp)) {
767 error = ttywait(tp);
768 if (error) {
764 splx(s);
765 return (error);
766 }
767 if (cmd == TIOCSETAF)
768 ttyflush(tp, FREAD);
769 }
770 if (!ISSET(t->c_cflag, CIGNORE)) {
771 /*

--- 93 unchanged lines hidden (view full) ---

865 (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0);
866#endif
867 }
868 splx(s);
869 break;
870 case TIOCSCTTY: /* become controlling tty */
871 /* Session ctty vnode pointer set in vnode layer. */
872 if (!SESS_LEADER(p) ||
769 splx(s);
770 return (error);
771 }
772 if (cmd == TIOCSETAF)
773 ttyflush(tp, FREAD);
774 }
775 if (!ISSET(t->c_cflag, CIGNORE)) {
776 /*

--- 93 unchanged lines hidden (view full) ---

870 (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0);
871#endif
872 }
873 splx(s);
874 break;
875 case TIOCSCTTY: /* become controlling tty */
876 /* Session ctty vnode pointer set in vnode layer. */
877 if (!SESS_LEADER(p) ||
873 (p->p_session->s_ttyvp || tp->t_session) &&
874 (tp->t_session != p->p_session))
878 ((p->p_session->s_ttyvp || tp->t_session) &&
879 (tp->t_session != p->p_session)))
875 return (EPERM);
876 tp->t_session = p->p_session;
877 tp->t_pgrp = p->p_pgrp;
878 p->p_session->s_ttyp = tp;
879 p->p_flag |= P_CONTROLT;
880 break;
881 case TIOCSPGRP: { /* set pgrp of tty */
882 register struct pgrp *pgrp = pgfind(*(int *)data);

--- 35 unchanged lines hidden (view full) ---

918 int nread, s;
919
920 tp = &cdevsw[major(device)].d_ttys[minor(device)];
921
922 s = spltty();
923 switch (rw) {
924 case FREAD:
925 nread = ttnread(tp);
880 return (EPERM);
881 tp->t_session = p->p_session;
882 tp->t_pgrp = p->p_pgrp;
883 p->p_session->s_ttyp = tp;
884 p->p_flag |= P_CONTROLT;
885 break;
886 case TIOCSPGRP: { /* set pgrp of tty */
887 register struct pgrp *pgrp = pgfind(*(int *)data);

--- 35 unchanged lines hidden (view full) ---

923 int nread, s;
924
925 tp = &cdevsw[major(device)].d_ttys[minor(device)];
926
927 s = spltty();
928 switch (rw) {
929 case FREAD:
930 nread = ttnread(tp);
926 if (nread > 0 || !ISSET(tp->t_cflag, CLOCAL) &&
927 !ISSET(tp->t_state, TS_CARR_ON))
931 if (nread > 0 || (!ISSET(tp->t_cflag, CLOCAL) &&
932 !ISSET(tp->t_state, TS_CARR_ON)))
928 goto win;
929 selrecord(p, &tp->t_rsel);
930 break;
931 case FWRITE:
932 if (tp->t_outq.c_cc <= tp->t_lowat) {
933win: splx(s);
934 return (1);
935 }

--- 29 unchanged lines hidden (view full) ---

965
966 error = 0;
967 s = spltty();
968 while ((tp->t_outq.c_cc || ISSET(tp->t_state, TS_BUSY)) &&
969 (ISSET(tp->t_state, TS_CARR_ON) || ISSET(tp->t_cflag, CLOCAL))
970 && tp->t_oproc) {
971 (*tp->t_oproc)(tp);
972 SET(tp->t_state, TS_ASLEEP);
933 goto win;
934 selrecord(p, &tp->t_rsel);
935 break;
936 case FWRITE:
937 if (tp->t_outq.c_cc <= tp->t_lowat) {
938win: splx(s);
939 return (1);
940 }

--- 29 unchanged lines hidden (view full) ---

970
971 error = 0;
972 s = spltty();
973 while ((tp->t_outq.c_cc || ISSET(tp->t_state, TS_BUSY)) &&
974 (ISSET(tp->t_state, TS_CARR_ON) || ISSET(tp->t_cflag, CLOCAL))
975 && tp->t_oproc) {
976 (*tp->t_oproc)(tp);
977 SET(tp->t_state, TS_ASLEEP);
973 if (error = ttysleep(tp,
974 &tp->t_outq, TTOPRI | PCATCH, ttyout, 0))
978 error = ttysleep(tp, &tp->t_outq, TTOPRI | PCATCH, ttyout, 0);
979 if (error)
975 break;
976 }
977 splx(s);
978 return (error);
979}
980
981/*
982 * Flush if successfully wait.

--- 66 unchanged lines hidden (view full) ---

1049 if (tp->t_rawq.c_cc > TTYHOG) {
1050 ttyflush(tp, FREAD | FWRITE);
1051 CLR(tp->t_state, TS_TBLOCK);
1052 }
1053 /*
1054 * Block further input iff: current input > threshold
1055 * AND input is available to user program.
1056 */
980 break;
981 }
982 splx(s);
983 return (error);
984}
985
986/*
987 * Flush if successfully wait.

--- 66 unchanged lines hidden (view full) ---

1054 if (tp->t_rawq.c_cc > TTYHOG) {
1055 ttyflush(tp, FREAD | FWRITE);
1056 CLR(tp->t_state, TS_TBLOCK);
1057 }
1058 /*
1059 * Block further input iff: current input > threshold
1060 * AND input is available to user program.
1061 */
1057 if (total >= TTYHOG / 2 &&
1062 if ((total >= TTYHOG / 2 &&
1058 !ISSET(tp->t_state, TS_TBLOCK) &&
1063 !ISSET(tp->t_state, TS_TBLOCK) &&
1059 !ISSET(tp->t_lflag, ICANON) || tp->t_canq.c_cc > 0 &&
1060 tp->t_cc[VSTOP] != _POSIX_VDISABLE) {
1064 !ISSET(tp->t_lflag, ICANON)) || (tp->t_canq.c_cc > 0 &&
1065 tp->t_cc[VSTOP] != _POSIX_VDISABLE)) {
1061 if (putc(tp->t_cc[VSTOP], &tp->t_outq) == 0) {
1062 SET(tp->t_state, TS_TBLOCK);
1063 ttstart(tp);
1064 }
1065 }
1066}
1067
1068void

--- 163 unchanged lines hidden (view full) ---

1232 * Hang process if it's in the background.
1233 */
1234 if (isbackground(p, tp)) {
1235 if ((p->p_sigignore & sigmask(SIGTTIN)) ||
1236 (p->p_sigmask & sigmask(SIGTTIN)) ||
1237 p->p_flag & P_PPWAIT || p->p_pgrp->pg_jobc == 0)
1238 return (EIO);
1239 pgsignal(p->p_pgrp, SIGTTIN, 1);
1066 if (putc(tp->t_cc[VSTOP], &tp->t_outq) == 0) {
1067 SET(tp->t_state, TS_TBLOCK);
1068 ttstart(tp);
1069 }
1070 }
1071}
1072
1073void

--- 163 unchanged lines hidden (view full) ---

1237 * Hang process if it's in the background.
1238 */
1239 if (isbackground(p, tp)) {
1240 if ((p->p_sigignore & sigmask(SIGTTIN)) ||
1241 (p->p_sigmask & sigmask(SIGTTIN)) ||
1242 p->p_flag & P_PPWAIT || p->p_pgrp->pg_jobc == 0)
1243 return (EIO);
1244 pgsignal(p->p_pgrp, SIGTTIN, 1);
1240 if (error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0))
1245 error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0);
1246 if (error)
1241 return (error);
1242 goto loop;
1243 }
1244
1245 /*
1246 * If canonical, use the canonical queue,
1247 * else use the raw queue.
1248 *

--- 35 unchanged lines hidden (view full) ---

1284 first = 1;
1285 while ((c = getc(qp)) >= 0) {
1286 /*
1287 * delayed suspend (^Y)
1288 */
1289 if (CCEQ(cc[VDSUSP], c) && ISSET(lflag, ISIG)) {
1290 pgsignal(tp->t_pgrp, SIGTSTP, 1);
1291 if (first) {
1247 return (error);
1248 goto loop;
1249 }
1250
1251 /*
1252 * If canonical, use the canonical queue,
1253 * else use the raw queue.
1254 *

--- 35 unchanged lines hidden (view full) ---

1290 first = 1;
1291 while ((c = getc(qp)) >= 0) {
1292 /*
1293 * delayed suspend (^Y)
1294 */
1295 if (CCEQ(cc[VDSUSP], c) && ISSET(lflag, ISIG)) {
1296 pgsignal(tp->t_pgrp, SIGTSTP, 1);
1297 if (first) {
1292 if (error = ttysleep(tp,
1293 &lbolt, TTIPRI | PCATCH, ttybg, 0))
1298 error = ttysleep(tp,
1299 &lbolt, TTIPRI | PCATCH, ttybg, 0);
1300 if (error)
1294 break;
1295 goto loop;
1296 }
1297 break;
1298 }
1299 /*
1300 * Interpret EOF only in canonical mode.
1301 */

--- 110 unchanged lines hidden (view full) ---

1412 */
1413 p = curproc;
1414 if (isbackground(p, tp) &&
1415 ISSET(tp->t_lflag, TOSTOP) && (p->p_flag & P_PPWAIT) == 0 &&
1416 (p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
1417 (p->p_sigmask & sigmask(SIGTTOU)) == 0 &&
1418 p->p_pgrp->pg_jobc) {
1419 pgsignal(p->p_pgrp, SIGTTOU, 1);
1301 break;
1302 goto loop;
1303 }
1304 break;
1305 }
1306 /*
1307 * Interpret EOF only in canonical mode.
1308 */

--- 110 unchanged lines hidden (view full) ---

1419 */
1420 p = curproc;
1421 if (isbackground(p, tp) &&
1422 ISSET(tp->t_lflag, TOSTOP) && (p->p_flag & P_PPWAIT) == 0 &&
1423 (p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
1424 (p->p_sigmask & sigmask(SIGTTOU)) == 0 &&
1425 p->p_pgrp->pg_jobc) {
1426 pgsignal(p->p_pgrp, SIGTTOU, 1);
1420 if (error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0))
1427 error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0);
1428 if (error)
1421 goto out;
1422 goto loop;
1423 }
1424 /*
1425 * Process the user's data in at most OBUFSIZ chunks. Perform any
1426 * output translation. Keep track of high water mark, sleep on
1427 * overflow awaiting device aid in acquiring new space.
1428 */

--- 36 unchanged lines hidden (view full) ---

1465 * If ce is zero, then we're processing
1466 * a special character through ttyoutput.
1467 */
1468 if (ce == 0) {
1469 tp->t_rocount = 0;
1470 if (ttyoutput(*cp, tp) >= 0) {
1471 /* No Clists, wait a bit. */
1472 ttstart(tp);
1429 goto out;
1430 goto loop;
1431 }
1432 /*
1433 * Process the user's data in at most OBUFSIZ chunks. Perform any
1434 * output translation. Keep track of high water mark, sleep on
1435 * overflow awaiting device aid in acquiring new space.
1436 */

--- 36 unchanged lines hidden (view full) ---

1473 * If ce is zero, then we're processing
1474 * a special character through ttyoutput.
1475 */
1476 if (ce == 0) {
1477 tp->t_rocount = 0;
1478 if (ttyoutput(*cp, tp) >= 0) {
1479 /* No Clists, wait a bit. */
1480 ttstart(tp);
1473 if (error = ttysleep(tp, &lbolt,
1474 TTOPRI | PCATCH, ttybuf, 0))
1481 error = ttysleep(tp, &lbolt,
1482 TTOPRI | PCATCH, ttybuf, 0);
1483 if (error)
1475 break;
1476 goto loop;
1477 }
1478 cp++;
1479 cc--;
1480 if (ISSET(tp->t_lflag, FLUSHO) ||
1481 tp->t_outq.c_cc > hiwat)
1482 goto ovhiwat;

--- 12 unchanged lines hidden (view full) ---

1495 i = b_to_q(cp, ce, &tp->t_outq);
1496 ce -= i;
1497 tp->t_column += ce;
1498 cp += ce, cc -= ce, tk_nout += ce;
1499 tp->t_outcc += ce;
1500 if (i > 0) {
1501 /* No Clists, wait a bit. */
1502 ttstart(tp);
1484 break;
1485 goto loop;
1486 }
1487 cp++;
1488 cc--;
1489 if (ISSET(tp->t_lflag, FLUSHO) ||
1490 tp->t_outq.c_cc > hiwat)
1491 goto ovhiwat;

--- 12 unchanged lines hidden (view full) ---

1504 i = b_to_q(cp, ce, &tp->t_outq);
1505 ce -= i;
1506 tp->t_column += ce;
1507 cp += ce, cc -= ce, tk_nout += ce;
1508 tp->t_outcc += ce;
1509 if (i > 0) {
1510 /* No Clists, wait a bit. */
1511 ttstart(tp);
1503 if (error = ttysleep(tp,
1504 &lbolt, TTOPRI | PCATCH, ttybuf, 0))
1512 error = ttysleep(tp,
1513 &lbolt, TTOPRI | PCATCH, ttybuf, 0);
1514 if (error)
1505 break;
1506 goto loop;
1507 }
1508 if (ISSET(tp->t_lflag, FLUSHO) ||
1509 tp->t_outq.c_cc > hiwat)
1510 break;
1511 }
1512 ttstart(tp);

--- 183 unchanged lines hidden (view full) ---

1696
1697 if (!ISSET(tp->t_state, TS_CNTTB))
1698 CLR(tp->t_lflag, FLUSHO);
1699 if ((!ISSET(tp->t_lflag, ECHO) &&
1700 (!ISSET(tp->t_lflag, ECHONL) || c == '\n')) ||
1701 ISSET(tp->t_lflag, EXTPROC))
1702 return;
1703 if (ISSET(tp->t_lflag, ECHOCTL) &&
1515 break;
1516 goto loop;
1517 }
1518 if (ISSET(tp->t_lflag, FLUSHO) ||
1519 tp->t_outq.c_cc > hiwat)
1520 break;
1521 }
1522 ttstart(tp);

--- 183 unchanged lines hidden (view full) ---

1706
1707 if (!ISSET(tp->t_state, TS_CNTTB))
1708 CLR(tp->t_lflag, FLUSHO);
1709 if ((!ISSET(tp->t_lflag, ECHO) &&
1710 (!ISSET(tp->t_lflag, ECHONL) || c == '\n')) ||
1711 ISSET(tp->t_lflag, EXTPROC))
1712 return;
1713 if (ISSET(tp->t_lflag, ECHOCTL) &&
1704 (ISSET(c, TTY_CHARMASK) <= 037 && c != '\t' && c != '\n' ||
1714 ((ISSET(c, TTY_CHARMASK) <= 037 && c != '\t' && c != '\n') ||
1705 ISSET(c, TTY_CHARMASK) == 0177)) {
1706 (void)ttyoutput('^', tp);
1707 CLR(c, ~TTY_CHARMASK);
1708 if (c == 0177)
1709 c = '?';
1710 else
1711 c += 'A' - 1;
1712 }

--- 94 unchanged lines hidden (view full) ---

1807 utime.tv_sec, (utime.tv_usec + 5000) / 10000);
1808
1809 /* Print system time. */
1810 ttyprintf(tp, "%d.%02ds ",
1811 stime.tv_sec, (stime.tv_usec + 5000) / 10000);
1812
1813#define pgtok(a) (((a) * NBPG) / 1024)
1814 /* Print percentage cpu, resident set size. */
1715 ISSET(c, TTY_CHARMASK) == 0177)) {
1716 (void)ttyoutput('^', tp);
1717 CLR(c, ~TTY_CHARMASK);
1718 if (c == 0177)
1719 c = '?';
1720 else
1721 c += 'A' - 1;
1722 }

--- 94 unchanged lines hidden (view full) ---

1817 utime.tv_sec, (utime.tv_usec + 5000) / 10000);
1818
1819 /* Print system time. */
1820 ttyprintf(tp, "%d.%02ds ",
1821 stime.tv_sec, (stime.tv_usec + 5000) / 10000);
1822
1823#define pgtok(a) (((a) * NBPG) / 1024)
1824 /* Print percentage cpu, resident set size. */
1815 tmp = pick->p_pctcpu * 10000 + FSCALE / 2 >> FSHIFT;
1825 tmp = (pick->p_pctcpu * 10000 + FSCALE / 2) >> FSHIFT;
1816 ttyprintf(tp, "%d%% %dk\n",
1817 tmp / 100,
1818 pick->p_stat == SIDL || pick->p_stat == SZOMB ? 0 :
1819#ifdef pmap_resident_count
1820 pgtok(pmap_resident_count(&pick->p_vmspace->vm_pmap))
1821#else
1822 pgtok(pick->p_vmspace->vm_rssize)
1823#endif

--- 110 unchanged lines hidden (view full) ---

1934 void *chan;
1935 int pri, timo;
1936 char *wmesg;
1937{
1938 int error;
1939 short gen;
1940
1941 gen = tp->t_gen;
1826 ttyprintf(tp, "%d%% %dk\n",
1827 tmp / 100,
1828 pick->p_stat == SIDL || pick->p_stat == SZOMB ? 0 :
1829#ifdef pmap_resident_count
1830 pgtok(pmap_resident_count(&pick->p_vmspace->vm_pmap))
1831#else
1832 pgtok(pick->p_vmspace->vm_rssize)
1833#endif

--- 110 unchanged lines hidden (view full) ---

1944 void *chan;
1945 int pri, timo;
1946 char *wmesg;
1947{
1948 int error;
1949 short gen;
1950
1951 gen = tp->t_gen;
1942 if (error = tsleep(chan, pri, wmesg, timo))
1952 error = tsleep(chan, pri, wmesg, timo);
1953 if (error)
1943 return (error);
1944 return (tp->t_gen == gen ? 0 : ERESTART);
1945}
1954 return (error);
1955 return (tp->t_gen == gen ? 0 : ERESTART);
1956}