while we do not condone killing of cats, fix LP#1058815

This commit is contained in:
tg 2012-10-30 20:06:49 +00:00
parent 0ce7dcf856
commit f5ccc2feb3

20
funcs.c
View File

@ -38,7 +38,7 @@
#endif #endif
#endif #endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.228 2012/10/21 21:55:03 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.229 2012/10/30 20:06:49 tg Exp $");
#if HAVE_KILLPG #if HAVE_KILLPG
/* /*
@ -3661,7 +3661,7 @@ c_realpath(const char **wp)
int int
c_cat(const char **wp) c_cat(const char **wp)
{ {
int fd = STDIN_FILENO, rv; int fd = STDIN_FILENO, rv, eno;
ssize_t n, w; ssize_t n, w;
const char *fn = "<stdin>"; const char *fn = "<stdin>";
char *buf, *cp; char *buf, *cp;
@ -3692,24 +3692,24 @@ c_cat(const char **wp)
if (fn[0] == '-' && fn[1] == '\0') if (fn[0] == '-' && fn[1] == '\0')
fd = STDIN_FILENO; fd = STDIN_FILENO;
else if ((fd = open(fn, O_RDONLY)) < 0) { else if ((fd = open(fn, O_RDONLY)) < 0) {
rv = errno; eno = errno;
bi_errorf("%s: %s", fn, strerror(rv)); bi_errorf("%s: %s", fn, strerror(eno));
rv = 1; rv = 1;
continue; continue;
} }
} }
while (/* CONSTCOND */ 1) { while (/* CONSTCOND */ 1) {
n = blocking_read(fd, (cp = buf), MKSH_CAT_BUFSIZ); n = blocking_read(fd, (cp = buf), MKSH_CAT_BUFSIZ);
if (n == -1) { eno = errno;
if (errno == EINTR) {
/* give the user a chance to ^C out */ /* give the user a chance to ^C out */
intrcheck(); intrcheck();
if (n == -1) {
if (eno == EINTR) {
/* interrupted, try again */ /* interrupted, try again */
continue; continue;
} }
/* an error occured during reading */ /* an error occured during reading */
rv = errno; bi_errorf("%s: %s", fn, strerror(eno));
bi_errorf("%s: %s", fn, strerror(rv));
rv = 1; rv = 1;
break; break;
} else if (n == 0) } else if (n == 0)
@ -3722,9 +3722,9 @@ c_cat(const char **wp)
/* interrupted, try again */ /* interrupted, try again */
continue; continue;
/* an error occured during writing */ /* an error occured during writing */
rv = errno; eno = errno;
bi_errorf("%s: %s", "<stdout>", bi_errorf("%s: %s", "<stdout>",
strerror(rv)); strerror(eno));
rv = 1; rv = 1;
if (fd != STDIN_FILENO) if (fd != STDIN_FILENO)
close(fd); close(fd);