BSD 4_3_Tahoe release
[unix-history] / usr / src / ucb / window / mloop.c
CommitLineData
60de5df9 1/*
46e9ea25
KB
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
5e8b0e60
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
60de5df9
EW
16 */
17
46e9ea25 18#ifndef lint
ca67e7b4 19static char sccsid[] = "@(#)mloop.c 3.13 (Berkeley) 6/29/88";
46e9ea25
KB
20#endif /* not lint */
21
3e02121b 22#include "defs.h"
07492ae5 23#include <sys/signal.h>
3e02121b
EW
24
25mloop()
26{
07492ae5 27 kill(getpid(), SIGIO); /* catch typeahead before ASYNC was set */
3e02121b 28 while (!quit) {
ffa20db4 29 if (incmd) {
3e02121b 30 docmd();
b1189050 31 } else if (wwcurwin->ww_state != WWS_HASPROC) {
2422abab
EW
32 if (!wwcurwin->ww_keepopen)
33 closewin(wwcurwin);
ffa20db4 34 setcmd(1);
b1189050
EW
35 if (wwpeekc() == escapec)
36 (void) wwgetc();
37 error("Process died.");
38 } else {
3fdb475b 39 register struct ww *w = wwcurwin;
b1189050
EW
40 register char *p;
41 register n;
42
2c279448
EW
43 if (wwibp >= wwibq)
44 wwiomux();
45 for (p = wwibp; p < wwibq && *p != escapec;
46 p++)
47 ;
48 if ((n = p - wwibp) > 0) {
49 if (!w->ww_ispty && w->ww_stopped)
50 startwin(w);
51 (void) write(w->ww_pty, wwibp, n);
52 wwibp = p;
53 }
54 if (wwpeekc() == escapec) {
55 (void) wwgetc();
56 setcmd(1);
3e02121b
EW
57 }
58 }
59 }
60}