files: block the resizing signal while reading from an external command

A SIGWINCH somehow causes the input stream to see EOT, with the result
that any remaining output of an external program would be lost.

This fixes https://savannah.gnu.org/bugs/?56038,
and fixes https://savannah.gnu.org/bugs/?56033.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
This commit is contained in:
Brand Huntsman
2019-03-31 17:17:45 -06:00
committed by Benno Schulenberg
parent 8e302738e8
commit 32431cddf8
3 changed files with 15 additions and 2 deletions

View File

@@ -800,6 +800,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
topline = make_new_node(NULL);
bottomline = topline;
#ifndef NANO_TINY
block_sigwinch(TRUE);
#endif
/* Lock the file before starting to read it, to avoid the overhead
* of locking it for each single byte that we read from it. */
flockfile(f);
@@ -875,6 +879,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
/* We are done with the file, unlock it. */
funlockfile(f);
#ifndef NANO_TINY
block_sigwinch(FALSE);
#endif
/* Perhaps this could use some better handling. */
if (ferror(f))
nperror(filename);