moved signal catching routines to ex_subr.c so they'll be in root ovly
[unix-history] / usr / src / usr.bin / ex / ex_put.c
index 222c82d..4bcdd00 100644 (file)
@@ -1,5 +1,5 @@
 /* Copyright (c) 1980 Regents of the University of California */
 /* Copyright (c) 1980 Regents of the University of California */
-static char *sccsid = "@(#)ex_put.c    4.2 %G%";
+static char *sccsid = "@(#)ex_put.c    6.4 %G%";
 #include "ex.h"
 #include "ex_tty.h"
 #include "ex_vis.h"
 #include "ex.h"
 #include "ex_tty.h"
 #include "ex_vis.h"
@@ -873,8 +873,33 @@ tostart()
 {
        putpad(VS);
        putpad(KS);
 {
        putpad(VS);
        putpad(KS);
-       if (!value(MESG))
-               chmod(ttynbuf, 0611);   /* 11 = urgent only allowed */
+       if (!value(MESG)) {
+               if (ttynbuf[0] == 0) {
+                       register char *tn;
+                       if ((tn=ttyname(2)) == NULL &&
+                           (tn=ttyname(1)) == NULL &&
+                           (tn=ttyname(0)) == NULL)
+                               ttynbuf[0] = 1;
+                       else
+                               strcpy(ttynbuf, tn);
+               }
+               if (ttynbuf[0] != 1) {
+                       struct stat sbuf;
+                       stat(ttynbuf, &sbuf);
+                       ttymesg = sbuf.st_mode & 0777;
+                       chmod(ttynbuf,
+#ifdef UCBV7
+       /*
+        * This applies to the UCB V7 Pdp-11 system with the
+        * -u write option only.
+        */
+                                       0611    /* 11 = urgent only allowed */
+#else
+                                       0600
+#endif
+                                               );
+               }
+       }
 }
 
 /*
 }
 
 /*
@@ -1014,8 +1039,6 @@ setty(f)
 gTTY(i)
        int i;
 {
 gTTY(i)
        int i;
 {
-       char *tn;
-       struct stat sbuf;
 
 #ifndef USG3TTY
        ignore(gtty(i, &tty));
 
 #ifndef USG3TTY
        ignore(gtty(i, &tty));
@@ -1023,18 +1046,13 @@ gTTY(i)
        ioctl(i, TIOCGETC, &ottyc);
        nttyc = ottyc;
 # endif
        ioctl(i, TIOCGETC, &ottyc);
        nttyc = ottyc;
 # endif
-# ifdef TIOCLGET
+# ifdef TIOCGLTC
        ioctl(i, TIOCGLTC, &olttyc);
        nlttyc = olttyc;
 # endif
 #else
        ioctl(i, TCGETA, &tty);
 #endif
        ioctl(i, TIOCGLTC, &olttyc);
        nlttyc = olttyc;
 # endif
 #else
        ioctl(i, TCGETA, &tty);
 #endif
-       if ((tn=ttyname(0)) == NULL && (tn=ttyname(1)) == NULL && (tn=ttyname(2)) == NULL)
-               tn = "/dev/tty";
-       strcpy(ttynbuf, tn);
-       stat(ttynbuf, &sbuf);
-       ttymesg = sbuf.st_mode & 0777;
 }
 
 /*
 }
 
 /*
@@ -1064,7 +1082,7 @@ sTTY(i)
        /* Update the other random chars while we're at it. */
        ioctl(i, TIOCSETC, &nttyc);
 # endif
        /* Update the other random chars while we're at it. */
        ioctl(i, TIOCSETC, &nttyc);
 # endif
-# ifdef TIOCLGET
+# ifdef TIOCSLTC
        ioctl(i, TIOCSLTC, &nlttyc);
 # endif
 
        ioctl(i, TIOCSLTC, &nlttyc);
 # endif
 
@@ -1082,39 +1100,3 @@ noonl()
 
        putchar(Outchar != termchar ? ' ' : '\n');
 }
 
        putchar(Outchar != termchar ? ' ' : '\n');
 }
-
-#ifdef TIOCLGET
-/*
- * We have just gotten a susp.  Suspend and prepare to resume.
- */
-onsusp()
-{
-       ttymode f;
-
-       f = setty(normf);
-       vnfl();
-       putpad(TE);
-       flush();
-
-       signal(SIGTSTP, SIG_DFL);
-       kill(0, SIGTSTP);
-
-       /* the pc stops here */
-
-       signal(SIGTSTP, onsusp);
-       vcontin(0);
-       setty(f);
-       if (!inopen)
-               error(0);
-       else {
-               if (vcnt < 0) {
-                       vcnt = -vcnt;
-                       if (state == VISUAL)
-                               vclear();
-                       else if (state == CRTOPEN)
-                               vcnt = 0;
-               }
-               vdirty(0, LINES);
-               vrepaint(cursor);
-       }
-}