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
1 changed files with 14 additions and 14 deletions

28
funcs.c
View File

@ -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: