summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorcracauer <cracauer@FreeBSD.org>1999-11-29 19:11:01 +0000
committercracauer <cracauer@FreeBSD.org>1999-11-29 19:11:01 +0000
commit903b2c868c14cd85dd3b2e2675969b9cb17f94ea (patch)
tree6ca499c12c2fb731744e3f10743e0e08fdad94e3 /bin
parent80af32c97b108dacf6028b29ecae08e5da839113 (diff)
downloadFreeBSD-src-903b2c868c14cd85dd3b2e2675969b9cb17f94ea.zip
FreeBSD-src-903b2c868c14cd85dd3b2e2675969b9cb17f94ea.tar.gz
Include strerror(errno) in error messages after failed system calls.
Fix a warning.
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/cd.c2
-rw-r--r--bin/sh/error.c1
-rw-r--r--bin/sh/eval.c7
-rw-r--r--bin/sh/input.c2
-rw-r--r--bin/sh/jobs.c8
-rw-r--r--bin/sh/main.c2
-rw-r--r--bin/sh/mkinit.c3
-rw-r--r--bin/sh/mknodes.c7
-rw-r--r--bin/sh/redir.c2
-rw-r--r--bin/sh/show.c2
10 files changed, 21 insertions, 15 deletions
diff --git a/bin/sh/cd.c b/bin/sh/cd.c
index ee65892..3ec8dee 100644
--- a/bin/sh/cd.c
+++ b/bin/sh/cd.c
@@ -342,7 +342,7 @@ getpwd()
INTOFF;
if (pipe(pip) < 0)
- error("Pipe call failed");
+ error("Pipe call failed: %s", strerror(errno));
jp = makejob((union node *)NULL, 1);
if (forkshell(jp, (union node *)NULL, FORK_NOJOB) == 0) {
(void) close(pip[0]);
diff --git a/bin/sh/error.c b/bin/sh/error.c
index f5dd6a6..e079699 100644
--- a/bin/sh/error.c
+++ b/bin/sh/error.c
@@ -51,6 +51,7 @@ static const char rcsid[] =
#include "options.h"
#include "output.h"
#include "error.h"
+#include "nodes.h" /* show.h needs nodes.h */
#include "show.h"
#include "trap.h"
#include <signal.h>
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index 0699a66..4f20822 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -45,6 +45,7 @@ static const char rcsid[] =
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h> /* For WIFSIGNALED(status) */
+#include <errno.h>
/*
* Evaluate a command.
@@ -488,7 +489,7 @@ evalpipe(n)
if (lp->next) {
if (pipe(pip) < 0) {
close(prevfd);
- error("Pipe call failed");
+ error("Pipe call failed: %s", strerror(errno));
}
}
if (forkshell(jp, lp->n, n->npipe.backgnd) == 0) {
@@ -556,7 +557,7 @@ evalbackcmd(n, result)
} else {
exitstatus = 0;
if (pipe(pip) < 0)
- error("Pipe call failed");
+ error("Pipe call failed: %s", strerror(errno));
jp = makejob(n, 1);
if (forkshell(jp, n, FORK_NOJOB) == 0) {
FORCEINTON;
@@ -728,7 +729,7 @@ evalcommand(cmd, flags, backcmd)
if (flags & EV_BACKCMD) {
mode = FORK_NOJOB;
if (pipe(pip) < 0)
- error("Pipe call failed");
+ error("Pipe call failed: %s", strerror(errno));
}
if (forkshell(jp, cmd, mode) != 0)
goto parent; /* at end of routine */
diff --git a/bin/sh/input.c b/bin/sh/input.c
index 809a335..d75dfa4 100644
--- a/bin/sh/input.c
+++ b/bin/sh/input.c
@@ -383,7 +383,7 @@ setinputfile(fname, push)
INTOFF;
if ((fd = open(fname, O_RDONLY)) < 0)
- error("Can't open %s", fname);
+ error("Can't open %s: %s", fname, strerror(errno));
if (fd < 10) {
fd2 = copyfd(fd, 10);
close(fd);
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c
index d33e74c..72a7bd2 100644
--- a/bin/sh/jobs.c
+++ b/bin/sh/jobs.c
@@ -594,7 +594,7 @@ forkshell(jp, n, mode)
if (pid == -1) {
TRACE(("Fork failed, errno=%d\n", errno));
INTON;
- error("Cannot fork");
+ error("Cannot fork: %s", strerror(errno));
}
if (pid == 0) {
struct job *p;
@@ -636,7 +636,8 @@ forkshell(jp, n, mode)
! fd0_redirected_p ()) {
close(0);
if (open("/dev/null", O_RDONLY) != 0)
- error("Can't open /dev/null");
+ error("Can't open /dev/null: %s",
+ strerror(errno));
}
}
#else
@@ -647,7 +648,8 @@ forkshell(jp, n, mode)
! fd0_redirected_p ()) {
close(0);
if (open("/dev/null", O_RDONLY) != 0)
- error("Can't open /dev/null");
+ error("Can't open /dev/null: %s",
+ strerror(errno));
}
}
#endif
diff --git a/bin/sh/main.c b/bin/sh/main.c
index 3a15230..0587161 100644
--- a/bin/sh/main.c
+++ b/bin/sh/main.c
@@ -300,7 +300,7 @@ readcmdfile(name)
if ((fd = open(name, O_RDONLY)) >= 0)
setinputfd(fd, 1);
else
- error("Can't open %s", name);
+ error("Can't open %s: %s", name, strerror(errno));
INTON;
cmdloop(0);
popfile();
diff --git a/bin/sh/mkinit.c b/bin/sh/mkinit.c
index e6de2d2..b8f8ffb 100644
--- a/bin/sh/mkinit.c
+++ b/bin/sh/mkinit.c
@@ -66,6 +66,7 @@ static const char rcsid[] =
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
+#include <errno.h>
/*
@@ -478,7 +479,7 @@ ckfopen(file, mode)
FILE *fp;
if ((fp = fopen(file, mode)) == NULL) {
- fprintf(stderr, "Can't open %s\n", file);
+ fprintf(stderr, "Can't open %s: %s\n", file, strerror(errno));
exit(2);
}
return fp;
diff --git a/bin/sh/mknodes.c b/bin/sh/mknodes.c
index 615668b..007cb32 100644
--- a/bin/sh/mknodes.c
+++ b/bin/sh/mknodes.c
@@ -56,6 +56,7 @@ static const char rcsid[] =
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#ifdef __STDC__
#include <stdarg.h>
#else
@@ -123,7 +124,7 @@ main(argc, argv)
if (argc != 3)
error("usage: mknodes file");
if ((infp = fopen(argv[1], "r")) == NULL)
- error("Can't open %s", argv[1]);
+ error("Can't open %s: %s", argv[1], strerror(errno));
while (readline()) {
if (line[0] == ' ' || line[0] == '\t')
parsefield();
@@ -232,9 +233,9 @@ output(file)
char *p;
if ((patfile = fopen(file, "r")) == NULL)
- error("Can't open %s", file);
+ error("Can't open %s: %s", file, strerror(errno));
if ((hfile = fopen("nodes.h", "w")) == NULL)
- error("Can't create nodes.h");
+ error("Can't create nodes.h: %s", strerror(errno));
if ((cfile = fopen("nodes.c", "w")) == NULL)
error("Can't create nodes.c");
fputs(writer, hfile);
diff --git a/bin/sh/redir.c b/bin/sh/redir.c
index 79b70d0..3ef30d0 100644
--- a/bin/sh/redir.c
+++ b/bin/sh/redir.c
@@ -246,7 +246,7 @@ openhere(redir)
int len = 0;
if (pipe(pip) < 0)
- error("Pipe call failed");
+ error("Pipe call failed: %s", strerror(errno));
if (redir->type == NHERE) {
len = strlen(redir->nhere.doc->narg.text);
if (len <= PIPESIZE) {
diff --git a/bin/sh/show.c b/bin/sh/show.c
index 620ffa4..b8c6f20b 100644
--- a/bin/sh/show.c
+++ b/bin/sh/show.c
@@ -420,7 +420,7 @@ opentrace() {
scopy("./trace", s);
#endif /* not_this_way */
if ((tracefile = fopen(s, "a")) == NULL) {
- fprintf(stderr, "Can't open %s\n", s);
+ fprintf(stderr, "Can't open %s: %s\n", s, strerror(errno));
return;
}
#ifdef O_APPEND
OpenPOWER on IntegriCloud