diff --git a/funcs.c b/funcs.c index ef4ab7e..741e9ad 100644 --- a/funcs.c +++ b/funcs.c @@ -38,7 +38,7 @@ #endif #endif -__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.295 2016/02/26 20:56:43 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.296 2016/06/25 23:52:46 tg Exp $"); #if HAVE_KILLPG /* @@ -2004,20 +2004,20 @@ c_read(const char **wp) } #endif - bytesread = blocking_read(fd, xp, bytesleft); - if (bytesread == (size_t)-1) { - /* interrupted */ - if (errno == EINTR && fatal_trap_check()) { - /* - * Was the offending signal one that would - * normally kill a process? If so, pretend - * the read was killed. - */ - rv = 2; - goto c_read_out; + if ((bytesread = blocking_read(fd, xp, bytesleft)) == (size_t)-1) { + if (errno == EINTR) { + /* check whether the signal would normally kill */ + if (!fatal_trap_check()) { + /* no, just ignore the signal */ + goto c_read_readloop; + } + /* pretend the read was killed */ + } else { + /* unexpected error */ + bi_errorf("%s", cstrerror(errno)); } - /* just ignore the signal */ - goto c_read_readloop; + rv = 2; + goto c_read_out; } c_read_didread: