mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-27 11:43:37 +08:00
Fix IO error handling in non-interactive reader
This used to use fread(2) which returns size_t, but read(2) returns an ssize_t of -1 on error. Fixes #6990
This commit is contained in:
parent
30a8345a11
commit
83c657c010
|
@ -3762,13 +3762,14 @@ static int read_ni(parser_t &parser, int fd, const io_chain_t &io) {
|
||||||
std::string fd_contents;
|
std::string fd_contents;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char buff[4096];
|
char buff[4096];
|
||||||
size_t amt = read(fd, buff, sizeof buff);
|
ssize_t amt = read(fd, buff, sizeof buff);
|
||||||
if (amt > 0) {
|
if (amt > 0) {
|
||||||
fd_contents.append(buff, amt);
|
fd_contents.append(buff, amt);
|
||||||
} else if (amt == 0) {
|
} else if (amt == 0) {
|
||||||
// EOF.
|
// EOF.
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
assert(amt == -1);
|
||||||
int err = errno;
|
int err = errno;
|
||||||
if (err == EINTR) {
|
if (err == EINTR) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user