From f5ccc2feb3976304d01a115a065d6286ebd155d7 Mon Sep 17 00:00:00 2001 From: tg Date: Tue, 30 Oct 2012 20:06:49 +0000 Subject: [PATCH] while we do not condone killing of cats, fix LP#1058815 --- funcs.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/funcs.c b/funcs.c index 5575adf..49064ae 100644 --- a/funcs.c +++ b/funcs.c @@ -38,7 +38,7 @@ #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 /* @@ -3661,7 +3661,7 @@ c_realpath(const char **wp) int c_cat(const char **wp) { - int fd = STDIN_FILENO, rv; + int fd = STDIN_FILENO, rv, eno; ssize_t n, w; const char *fn = ""; char *buf, *cp; @@ -3692,24 +3692,24 @@ c_cat(const char **wp) if (fn[0] == '-' && fn[1] == '\0') fd = STDIN_FILENO; else if ((fd = open(fn, O_RDONLY)) < 0) { - rv = errno; - bi_errorf("%s: %s", fn, strerror(rv)); + eno = errno; + bi_errorf("%s: %s", fn, strerror(eno)); rv = 1; continue; } } while (/* CONSTCOND */ 1) { n = blocking_read(fd, (cp = buf), MKSH_CAT_BUFSIZ); + eno = errno; + /* give the user a chance to ^C out */ + intrcheck(); if (n == -1) { - if (errno == EINTR) { - /* give the user a chance to ^C out */ - intrcheck(); + if (eno == EINTR) { /* interrupted, try again */ continue; } /* an error occured during reading */ - rv = errno; - bi_errorf("%s: %s", fn, strerror(rv)); + bi_errorf("%s: %s", fn, strerror(eno)); rv = 1; break; } else if (n == 0) @@ -3722,9 +3722,9 @@ c_cat(const char **wp) /* interrupted, try again */ continue; /* an error occured during writing */ - rv = errno; + eno = errno; bi_errorf("%s: %s", "", - strerror(rv)); + strerror(eno)); rv = 1; if (fd != STDIN_FILENO) close(fd);