files: do not call fsync() on a fifo, to avoid a spurious error message

This fixes https://savannah.gnu.org/bugs/?61234.

The original report was in:
  https://lists.gnu.org/archive/html/nano-devel/2021-09/msg00029.html
Reported-by: André Kugland <kugland@gmail.com>

Bug existed since version 5.0, commit a84cdaaa.
master
Benno Schulenberg 2021-09-27 17:15:57 +02:00
parent 2087c20a83
commit a2b20a1915
1 changed files with 2 additions and 1 deletions

View File

@ -1953,8 +1953,9 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
unlink(tempname);
}
#endif
if (!S_ISFIFO(st.st_mode))
#endif
/* Ensure the data has reached the disk before reporting it as written. */
if (fflush(thefile) != 0 || fsync(fileno(thefile)) != 0) {
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));