BSD 4_4_Lite2 release
[unix-history] / usr / src / bin / sh / error.c
index b6853b6..d175451 100644 (file)
@@ -35,7 +35,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)error.c    8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)error.c    8.2 (Berkeley) 5/4/95";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -47,12 +47,9 @@ static char sccsid[] = "@(#)error.c  8.1 (Berkeley) 5/31/93";
 #include "options.h"
 #include "output.h"
 #include "error.h"
 #include "options.h"
 #include "output.h"
 #include "error.h"
+#include "show.h"
 #include <signal.h>
 #include <signal.h>
-#ifdef __STDC__
-#include "stdarg.h"
-#else
-#include <varargs.h>   
-#endif
+#include <unistd.h>
 #include <errno.h>
 
 
 #include <errno.h>
 
 
@@ -74,7 +71,9 @@ char *commandname;
  */
 
 void
  */
 
 void
-exraise(e) {
+exraise(e) 
+       int e;
+{
        if (handler == NULL)
                abort();
        exception = e;
        if (handler == NULL)
                abort();
        exception = e;
@@ -94,14 +93,15 @@ exraise(e) {
 
 void
 onint() {
 
 void
 onint() {
+       sigset_t sigset;
+
        if (suppressint) {
                intpending++;
                return;
        }
        intpending = 0;
        if (suppressint) {
                intpending++;
                return;
        }
        intpending = 0;
-#ifdef BSD
-       sigsetmask(0);
-#endif
+       sigemptyset(&sigset);
+       sigprocmask(SIG_SETMASK, &sigset, NULL);
        if (rootshell && iflag)
                exraise(EXINT);
        else
        if (rootshell && iflag)
                exraise(EXINT);
        else
@@ -124,21 +124,23 @@ error2(a, b)
  * formatting.  It then raises the error exception.
  */
 
  * formatting.  It then raises the error exception.
  */
 
-#ifdef __STDC__
+#if __STDC__
 void
 void
-error(char *msg, ...) {
+error(char *msg, ...)
 #else
 void
 error(va_alist)
        va_dcl
 #else
 void
 error(va_alist)
        va_dcl
-       {
+#endif
+{
+#if !__STDC__
        char *msg;
 #endif
        va_list ap;
        char *msg;
 #endif
        va_list ap;
-
        CLEAR_PENDING_INT;
        INTOFF;
        CLEAR_PENDING_INT;
        INTOFF;
-#ifdef __STDC__
+
+#if __STDC__
        va_start(ap, msg);
 #else
        va_start(ap);
        va_start(ap, msg);
 #else
        va_start(ap);
@@ -177,55 +179,57 @@ struct errname {
 #define ALL (E_OPEN|E_CREAT|E_EXEC)
 
 STATIC const struct errname errormsg[] = {
 #define ALL (E_OPEN|E_CREAT|E_EXEC)
 
 STATIC const struct errname errormsg[] = {
-       EINTR, ALL,     "interrupted",
-       EACCES, ALL,    "permission denied",
-       EIO, ALL,               "I/O error",
-       ENOENT, E_OPEN, "no such file",
-       ENOENT, E_CREAT,        "directory nonexistent",
-       ENOENT, E_EXEC, "not found",
-       ENOTDIR, E_OPEN,        "no such file",
-       ENOTDIR, E_CREAT,       "directory nonexistent",
-       ENOTDIR, E_EXEC,        "not found",
-       EISDIR, ALL,    "is a directory",
-/*    EMFILE, ALL,     "too many open files", */
-       ENFILE, ALL,    "file table overflow",
-       ENOSPC, ALL,    "file system full",
+       { EINTR,        ALL,    "interrupted" },
+       { EACCES,       ALL,    "permission denied" },
+       { EIO,          ALL,    "I/O error" },
+       { ENOENT,       E_OPEN, "no such file" },
+       { ENOENT,       E_CREAT,"directory nonexistent" },
+       { ENOENT,       E_EXEC, "not found" },
+       { ENOTDIR,      E_OPEN, "no such file" },
+       { ENOTDIR,      E_CREAT,"directory nonexistent" },
+       { ENOTDIR,      E_EXEC, "not found" },
+       { EISDIR,       ALL,    "is a directory" },
+#ifdef notdef
+       { EMFILE,       ALL,    "too many open files" },
+#endif
+       { ENFILE,       ALL,    "file table overflow" },
+       { ENOSPC,       ALL,    "file system full" },
 #ifdef EDQUOT
 #ifdef EDQUOT
-       EDQUOT, ALL,    "disk quota exceeded",
+       { EDQUOT,       ALL,    "disk quota exceeded" },
 #endif
 #ifdef ENOSR
 #endif
 #ifdef ENOSR
-       ENOSR, ALL,     "no streams resources",
+       { ENOSR,        ALL,    "no streams resources" },
 #endif
 #endif
-       ENXIO, ALL,     "no such device or address",
-       EROFS, ALL,     "read-only file system",
-       ETXTBSY, ALL,   "text busy",
+       { ENXIO,        ALL,    "no such device or address" },
+       { EROFS,        ALL,    "read-only file system" },
+       { ETXTBSY,      ALL,    "text busy" },
 #ifdef SYSV
 #ifdef SYSV
-       EAGAIN, E_EXEC, "not enough memory",
+       { EAGAIN,       E_EXEC, "not enough memory" },
 #endif
 #endif
-       ENOMEM, ALL,    "not enough memory",
+       { ENOMEM,       ALL,    "not enough memory" },
 #ifdef ENOLINK
 #ifdef ENOLINK
-       ENOLINK, ALL,   "remote access failed",
+       { ENOLINK,      ALL,    "remote access failed" },
 #endif
 #ifdef EMULTIHOP
 #endif
 #ifdef EMULTIHOP
-       EMULTIHOP, ALL, "remote access failed",
+       { EMULTIHOP,    ALL,    "remote access failed" },
 #endif
 #ifdef ECOMM
 #endif
 #ifdef ECOMM
-       ECOMM, ALL,     "remote access failed",
+       { ECOMM,        ALL,    "remote access failed" },
 #endif
 #ifdef ESTALE
 #endif
 #ifdef ESTALE
-       ESTALE, ALL,    "remote access failed",
+       { ESTALE,       ALL,    "remote access failed" },
 #endif
 #ifdef ETIMEDOUT
 #endif
 #ifdef ETIMEDOUT
-       ETIMEDOUT, ALL, "remote access failed",
+       { ETIMEDOUT,    ALL,    "remote access failed" },
 #endif
 #ifdef ELOOP
 #endif
 #ifdef ELOOP
-       ELOOP, ALL,     "symbolic link loop",
+       { ELOOP,        ALL,    "symbolic link loop" },
 #endif
 #endif
-       E2BIG, E_EXEC,  "argument list too long",
+       { E2BIG,        E_EXEC, "argument list too long" },
 #ifdef ELIBACC
 #ifdef ELIBACC
-       ELIBACC, E_EXEC,        "shared library missing",
+       { ELIBACC,      E_EXEC, "shared library missing" },
 #endif
 #endif
-       0, 0,           NULL
+       { 0,            0,      NULL },
 };
 
 
 };
 
 
@@ -236,7 +240,10 @@ STATIC const struct errname errormsg[] = {
  */
 
 char *
  */
 
 char *
-errmsg(e, action) {
+errmsg(e, action) 
+       int e;
+       int action;
+{
        struct errname const *ep;
        static char buf[12];
 
        struct errname const *ep;
        static char buf[12];