diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-11-26 21:17:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-26 21:17:35 +0100 |
commit | a043899ba255524b7421579b9bd6112801f09247 (patch) | |
tree | e4dc3cc54e327310ab661de5125ce37313670aa1 /src/nvim/quickfix.c | |
parent | 207b7ca4bc16d52641eaa5244eef25a0dba91dbc (diff) | |
parent | bab2f8200aea09ad32bbcb2e83404bbd4076a227 (diff) | |
download | rneovim-a043899ba255524b7421579b9bd6112801f09247.tar.gz rneovim-a043899ba255524b7421579b9bd6112801f09247.tar.bz2 rneovim-a043899ba255524b7421579b9bd6112801f09247.zip |
Merge #7633 'Retry fgets on EINTR'
closes #7632
Diffstat (limited to 'src/nvim/quickfix.c')
-rw-r--r-- | src/nvim/quickfix.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index b9228e15b9..1fc585f0c9 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -570,7 +570,12 @@ static int qf_get_next_file_line(qfstate_T *state) { size_t growbuflen; +retry: + errno = 0; if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL) { + if (errno == EINTR) { + goto retry; + } return QF_END_OF_INPUT; } @@ -590,8 +595,12 @@ static int qf_get_next_file_line(qfstate_T *state) growbuflen = state->linelen; for (;;) { + errno = 0; if (fgets((char *)state->growbuf + growbuflen, (int)(state->growbufsiz - growbuflen), state->fd) == NULL) { + if (errno == EINTR) { + continue; + } break; } state->linelen = STRLEN(state->growbuf + growbuflen); @@ -612,9 +621,14 @@ static int qf_get_next_file_line(qfstate_T *state) while (discard) { // The current line is longer than LINE_MAXLEN, continue reading but // discard everything until EOL or EOF is reached. - if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL - || STRLEN(IObuff) < IOSIZE - 1 - || IObuff[IOSIZE - 1] == '\n') { + errno = 0; + if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL) { + if (errno == EINTR) { + continue; + } + break; + } + if (STRLEN(IObuff) < IOSIZE - 1 || IObuff[IOSIZE - 1] == '\n') { break; } } |