abort read builtin in case of read(2) errors

noticed by arekm, persuaded by jilles, compared with other equivalent
pieces of code reading in mksh
This commit is contained in:
tg 2016-06-25 23:52:46 +00:00
parent 2dde57ab54
commit 1563b70658

28
funcs.c
View File

@ -38,7 +38,7 @@
#endif #endif
#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 #if HAVE_KILLPG
/* /*
@ -2004,20 +2004,20 @@ c_read(const char **wp)
} }
#endif #endif
bytesread = blocking_read(fd, xp, bytesleft); if ((bytesread = blocking_read(fd, xp, bytesleft)) == (size_t)-1) {
if (bytesread == (size_t)-1) { if (errno == EINTR) {
/* interrupted */ /* check whether the signal would normally kill */
if (errno == EINTR && fatal_trap_check()) { if (!fatal_trap_check()) {
/* /* no, just ignore the signal */
* Was the offending signal one that would goto c_read_readloop;
* normally kill a process? If so, pretend }
* the read was killed. /* pretend the read was killed */
*/ } else {
rv = 2; /* unexpected error */
goto c_read_out; bi_errorf("%s", cstrerror(errno));
} }
/* just ignore the signal */ rv = 2;
goto c_read_readloop; goto c_read_out;
} }
c_read_didread: c_read_didread: