emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 1a65afb: Don’t worry about unlink if errno == ENOE


From: Paul Eggert
Subject: [Emacs-diffs] master 1a65afb: Don’t worry about unlink if errno == ENOENT
Date: Tue, 1 Aug 2017 20:24:56 -0400 (EDT)

branch: master
commit 1a65afb7ecc2a52127d6164bad19313440237f9d
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Don’t worry about unlink if errno == ENOENT
    
    * src/fileio.c (Fdelete_file):
    * src/keyboard.c (Fopen_dribble_file): Do not report failure to
    remove a file if unlink fails with errno == ENOENT.  This can
    happen even if Emacs is the only program removing the file, in
    case an NFS cache overflows.  The file does not exist if errno ==
    ENOENT, so it is OK to proceed.
---
 src/fileio.c   | 2 +-
 src/keyboard.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/fileio.c b/src/fileio.c
index a57d50b..7531214 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2216,7 +2216,7 @@ With a prefix argument, TRASH is nil.  */)
 
   encoded_file = ENCODE_FILE (filename);
 
-  if (unlink (SSDATA (encoded_file)) < 0)
+  if (unlink (SSDATA (encoded_file)) != 0 && errno != ENOENT)
     report_file_error ("Removing old name", filename);
   return Qnil;
 }
diff --git a/src/keyboard.c b/src/keyboard.c
index 804af85..97069a2 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -10168,7 +10168,8 @@ This may include sensitive information such as 
passwords.  */)
       file = Fexpand_file_name (file, Qnil);
       encfile = ENCODE_FILE (file);
       fd = emacs_open (SSDATA (encfile), O_WRONLY | O_CREAT | O_EXCL, 0600);
-      if (fd < 0 && errno == EEXIST && unlink (SSDATA (encfile)) == 0)
+      if (fd < 0 && errno == EEXIST
+         && (unlink (SSDATA (encfile)) == 0 || errno == ENOENT))
        fd = emacs_open (SSDATA (encfile), O_WRONLY | O_CREAT | O_EXCL, 0600);
       dribble = fd < 0 ? 0 : fdopen (fd, "w");
       if (dribble == 0)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]