mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-27 04:05:08 +00:00
Fix for issue where a file may be incompletely read on receipt of a signal.
This commit is contained in:
parent
3f172d13b2
commit
42497d9932
1 changed files with 12 additions and 11 deletions
23
reader.cpp
23
reader.cpp
|
@ -3627,22 +3627,23 @@ static int read_ni(int fd, const io_chain_t &io)
|
||||||
{
|
{
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
{
|
{
|
||||||
/* We got a signal, just keep going */
|
/* We got a signal, just keep going. Be sure that we call insert() below because we may get data as well as EINTR. */
|
||||||
continue;
|
clearerr(in_stream);
|
||||||
}
|
}
|
||||||
else if ((errno == EAGAIN || errno == EWOULDBLOCK) && make_fd_blocking(des) == 0)
|
else if ((errno == EAGAIN || errno == EWOULDBLOCK) && make_fd_blocking(des) == 0)
|
||||||
{
|
{
|
||||||
/* We succeeded in making the fd blocking, try again */
|
/* We succeeded in making the fd blocking, keep going */
|
||||||
continue;
|
clearerr(in_stream);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/* Fatal error */
|
{
|
||||||
debug(1, _(L"Error while reading from file descriptor"));
|
/* Fatal error */
|
||||||
|
debug(1, _(L"Error while reading from file descriptor"));
|
||||||
/* Reset buffer on error. We won't evaluate incomplete files. */
|
|
||||||
acc.clear();
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
/* Reset buffer on error. We won't evaluate incomplete files. */
|
||||||
|
acc.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
acc.insert(acc.end(), buff, buff + c);
|
acc.insert(acc.end(), buff, buff + c);
|
||||||
|
|
Loading…
Reference in a new issue