Fixes from Chris Demetriou and Charles Hannum
authorChristos Zoulas <christos@ucbvax.Berkeley.EDU>
Sun, 30 Apr 1995 04:09:09 +0000 (20:09 -0800)
committerChristos Zoulas <christos@ucbvax.Berkeley.EDU>
Sun, 30 Apr 1995 04:09:09 +0000 (20:09 -0800)
SCCS-vsn: bin/csh/lex.c 8.2
SCCS-vsn: bin/csh/dol.c 8.2
SCCS-vsn: bin/csh/csh.c 8.4
SCCS-vsn: bin/csh/csh.h 8.2
SCCS-vsn: bin/csh/dir.c 8.2
SCCS-vsn: bin/csh/sem.c 8.3

usr/src/bin/csh/csh.c
usr/src/bin/csh/csh.h
usr/src/bin/csh/dir.c
usr/src/bin/csh/dol.c
usr/src/bin/csh/lex.c
usr/src/bin/csh/sem.c

index 99c0197..14054fd 100644 (file)
@@ -12,7 +12,7 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)csh.c      8.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)csh.c      8.4 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -246,11 +246,9 @@ main(argc, argv)
     (void) sigaction(SIGTERM, NULL, &oact);
     parterm = oact.sa_handler;
 
     (void) sigaction(SIGTERM, NULL, &oact);
     parterm = oact.sa_handler;
 
-    if (loginsh) {
-       (void) signal(SIGHUP, phup);    /* exit processing on HUP */
-       (void) signal(SIGXCPU, phup);   /* ...and on XCPU */
-       (void) signal(SIGXFSZ, phup);   /* ...and on XFSZ */
-    }
+    (void) signal(SIGHUP, phup);       /* exit processing on HUP */
+    (void) signal(SIGXCPU, phup);      /* ...and on XCPU */
+    (void) signal(SIGXFSZ, phup);      /* ...and on XFSZ */
 
     /*
      * Process the arguments.
 
     /*
      * Process the arguments.
@@ -707,7 +705,7 @@ srcunit(unit, onlyown, hflg)
        sigprocmask(SIG_BLOCK, &sigset, &osigset);
     }
     /* Setup the new values of the state stuff saved above */
        sigprocmask(SIG_BLOCK, &sigset, &osigset);
     }
     /* Setup the new values of the state stuff saved above */
-    bcopy((char *) &B, (char *) &(saveB), sizeof(B));
+    memmove(&saveB, &B, sizeof(B));
     fbuf = NULL;
     fseekp = feobp = fblocks = 0;
     oSHIN = SHIN, SHIN = unit, arginp = 0, onelflg = 0;
     fbuf = NULL;
     fseekp = feobp = fblocks = 0;
     oSHIN = SHIN, SHIN = unit, arginp = 0, onelflg = 0;
@@ -741,7 +739,7 @@ srcunit(unit, onlyown, hflg)
        xfree((ptr_t) fbuf);
 
        /* Reset input arena */
        xfree((ptr_t) fbuf);
 
        /* Reset input arena */
-       bcopy((char *) &(saveB), (char *) &B, sizeof(B));
+       memmove(&B, &saveB, sizeof(B));
 
        (void) close(SHIN), SHIN = oSHIN;
        arginp = oarginp, onelflg = oonelflg;
 
        (void) close(SHIN), SHIN = oSHIN;
        arginp = oarginp, onelflg = oonelflg;
@@ -790,7 +788,8 @@ rechist()
            (void) Strcat(buf, STRsldthist);
        }
 
            (void) Strcat(buf, STRsldthist);
        }
 
-       if ((fp = creat(short2str(hfile), 0600)) == -1) 
+       if ((fp = open(short2str(hfile), O_WRONLY | O_CREAT | O_TRUNC,
+           0600)) == -1) 
            return;
 
        oldidfds = didfds;
            return;
 
        oldidfds = didfds;
@@ -882,7 +881,7 @@ int sig;
            while ((np = np->p_friends) != pp);
        }
     }
            while ((np = np->p_friends) != pp);
        }
     }
-    _exit(sig);
+    xexit(sig);
 }
 
 Char   *jobargv[2] = {STRjobs, 0};
 }
 
 Char   *jobargv[2] = {STRjobs, 0};
index 12417de..4ee07cb 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)csh.h       8.1 (Berkeley) %G%
+ *     @(#)csh.h       8.2 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -160,8 +160,8 @@ jmp_buf reslab;
 #define        setexit()       (setjmp(reslab))
 #define        reset()         longjmp(reslab, 1)
  /* Should use structure assignment here */
 #define        setexit()       (setjmp(reslab))
 #define        reset()         longjmp(reslab, 1)
  /* Should use structure assignment here */
-#define        getexit(a)      bcopy((char *)reslab, ((char *)(a)), sizeof reslab)
-#define        resexit(a)      bcopy((char *)(a), (char *)reslab, sizeof reslab)
+#define        getexit(a)      memmove((a), reslab, sizeof reslab)
+#define        resexit(a)      memmove(reslab, (a), sizeof reslab)
 
 Char   *gointr;                        /* Label for an onintr transfer */
 
 
 Char   *gointr;                        /* Label for an onintr transfer */
 
index 276a9dc..ca1a0c2 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)dir.c      8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)dir.c      8.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -54,9 +54,9 @@ dinit(hp)
     static char *emsg = "csh: Trying to start from \"%s\"\n";
 
     /* Don't believe the login shell home, because it may be a symlink */
     static char *emsg = "csh: Trying to start from \"%s\"\n";
 
     /* Don't believe the login shell home, because it may be a symlink */
-    tcp = getwd(path);         /* see ngetwd.c for System V version */
+    tcp = getcwd(path, MAXPATHLEN);
     if (tcp == NULL || *tcp == '\0') {
     if (tcp == NULL || *tcp == '\0') {
-       (void) fprintf(csherr, "csh: %s\n", path);
+       (void) fprintf(csherr, "csh: %s\n", strerror(errno));
        if (hp && *hp) {
            tcp = short2str(hp);
            if (chdir(tcp) == -1)
        if (hp && *hp) {
            tcp = short2str(hp);
            if (chdir(tcp) == -1)
index bc8002d..77ba8a4 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)dol.c      8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)dol.c      8.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -820,16 +820,9 @@ heredoc(term)
     bool    quoted;
     char   *tmp;
 
     bool    quoted;
     char   *tmp;
 
-    if (creat(tmp = short2str(shtemp), 0600) < 0)
+    tmp = short2str(shtemp);
+    if (open(tmp, O_RDWR | O_CREAT | O_TRUNC, 0600) < 0)
        stderror(ERR_SYSTEM, tmp, strerror(errno));
        stderror(ERR_SYSTEM, tmp, strerror(errno));
-    (void) close(0);
-    if (open(tmp, O_RDWR) < 0) {
-       int     oerrno = errno;
-
-       (void) unlink(tmp);
-       errno = oerrno;
-       stderror(ERR_SYSTEM, tmp, strerror(errno));
-    }
     (void) unlink(tmp);                /* 0 0 inode! */
     Dv[0] = term;
     Dv[1] = NULL;
     (void) unlink(tmp);                /* 0 0 inode! */
     Dv[0] = term;
     Dv[1] = NULL;
index 43bd49e..4ef2e0e 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)lex.c      8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)lex.c      8.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -1477,7 +1477,7 @@ again:
                    goto again;
                }
                if (c > 0)
                    goto again;
                }
                if (c > 0)
-                   bcopy(ttyline, fbuf[buf] + off, c * sizeof(Char));
+                   memmove(fbuf[buf] + off, ttyline, c * sizeof(Char));
                numleft = 0;
            }
            else {
                numleft = 0;
            }
            else {
index 14ab192..6a567a1 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)sem.c      8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)sem.c      8.3 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -572,7 +572,7 @@ doio(t, pipein, pipeout)
                    stderror(ERR_SYSTEM, tmp, strerror(errno));
                chkclob(tmp);
            }
                    stderror(ERR_SYSTEM, tmp, strerror(errno));
                chkclob(tmp);
            }
-           if ((fd = creat(tmp, 0666)) < 0)
+           if ((fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
                stderror(ERR_SYSTEM, tmp, strerror(errno));
        }
        (void) dmove(fd, 1);
                stderror(ERR_SYSTEM, tmp, strerror(errno));
        }
        (void) dmove(fd, 1);