From 7546179a011452c304022349d034a03303a11ebb Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 8 May 2022 15:41:46 +0200 Subject: [PATCH] Don't hang on trying to rename FIFOs between file systems * src/fileio.c (Frename_file): Don't hang on trying to move FIFOs (bug#34069). --- src/fileio.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/fileio.c b/src/fileio.c index c418036fc6e..0610f7235a5 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2718,6 +2718,20 @@ This is what happens in interactive use with M-x. */) : Qnil); if (!NILP (symlink_target)) Fmake_symbolic_link (symlink_target, newname, ok_if_already_exists); + else if (S_ISFIFO (file_st.st_mode)) + { + /* If it's a FIFO, calling `copy-file' will hang if it's a + inter-file system move, so do it here. (It will signal + an error in that case, but it won't hang in any case.) */ + if (!NILP (ok_if_already_exists)) + barf_or_query_if_file_exists (newname, false, + "rename to it", + FIXNUMP (ok_if_already_exists), + false); + if (rename (SSDATA (encoded_file), SSDATA (encoded_newname)) != 0) + report_file_errno ("Renaming", list2 (file, newname), errno); + return Qnil; + } else Fcopy_file (file, newname, ok_if_already_exists, Qt, Qt, Qt); } -- 2.39.2