mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 21:33:09 +00: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
1 changed files with 2 additions and 1 deletions
|
@ -3762,13 +3762,14 @@ static int read_ni(parser_t &parser, int fd, const io_chain_t &io) {
|
|||
std::string fd_contents;
|
||||
for (;;) {
|
||||
char buff[4096];
|
||||
size_t amt = read(fd, buff, sizeof buff);
|
||||
ssize_t amt = read(fd, buff, sizeof buff);
|
||||
if (amt > 0) {
|
||||
fd_contents.append(buff, amt);
|
||||
} else if (amt == 0) {
|
||||
// EOF.
|
||||
break;
|
||||
} else {
|
||||
assert(amt == -1);
|
||||
int err = errno;
|
||||
if (err == EINTR) {
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue