files: prepending to a fifo makes no sense, so do not try that

Trying to prepend would hang nano until some other process writes
something to the fifo.

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

Bug existed since before version 2.2.4.
master
Benno Schulenberg 2021-09-28 10:05:23 +02:00
parent bb3d367716
commit 9ab49658d7
1 changed files with 5 additions and 0 deletions

View File

@ -1799,6 +1799,11 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
goto cleanup_and_exit;
}
if (method == PREPEND && is_existing_file && S_ISFIFO(st.st_mode)) {
statusline(ALERT, _("Error writing %s: %s"), realname, "FIFO");
goto cleanup_and_exit;
}
/* When prepending, first copy the existing file to a temporary file. */
if (method == PREPEND) {
FILE *source = fopen(realname, "rb");