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;
|
||||
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 New Issue
Block a user