Don’t hang when copying FIFOs

* src/fileio.c (Fcopy_file): Open the input file with O_NONBLOCK.
This prevents a hang if the input file is a FIFO.
If it’s a regular file O_NONBLOCK has no effect;
otherwise the file is soon rejected anyway.
This commit is contained in:
Paul Eggert 2022-12-18 11:45:06 -08:00
parent 09b5f00613
commit ab3cfa4a17

View file

@ -2219,7 +2219,7 @@ permissions. */)
report_file_error ("Copying permissions to", newname);
}
#else /* not WINDOWSNT */
ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0);
ifd = emacs_open (SSDATA (encoded_file), O_RDONLY | O_NONBLOCK, 0);
if (ifd < 0)
report_file_error ("Opening input file", file);