aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2024-08-15 13:30:23 -0700
committerPaul Eggert2024-08-15 13:31:31 -0700
commit8b36bfc553b97cf435bdfe1b84abe21c3a605b9f (patch)
tree745c4915cc9eb30c10fa8872398f05b07dfdbe69 /src
parent775fa8443faa3d7f5ce7f7d0aa6e6fb53321715a (diff)
downloademacs-8b36bfc553b97cf435bdfe1b84abe21c3a605b9f.tar.gz
emacs-8b36bfc553b97cf435bdfe1b84abe21c3a605b9f.zip
Remove empty (& invalid) lock files
* src/filelock.c (current_lock_owner): Remove empty lock files, as they are necessarily invalid and can be caused by buggy file systems. Problem reported by Michal Nazarewicz (bug#72641).
Diffstat (limited to 'src')
-rw-r--r--src/filelock.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/filelock.c b/src/filelock.c
index c68aacc46fb..1ae57dc7344 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -397,8 +397,8 @@ current_lock_owner (lock_info_type *owner, Lisp_Object lfname)
397 if (lfinfolen < 0) 397 if (lfinfolen < 0)
398 return errno == ENOENT || errno == ENOTDIR ? 0 : errno; 398 return errno == ENOENT || errno == ENOTDIR ? 0 : errno;
399 399
400 /* Examine lock file contents. */ 400 /* If the lock file seems valid, return a value based on its contents. */
401 if (true) 401 if (lfinfolen)
402 { 402 {
403 if (MAX_LFINFO < lfinfolen) 403 if (MAX_LFINFO < lfinfolen)
404 return ENAMETOOLONG; 404 return ENAMETOOLONG;
@@ -496,8 +496,11 @@ current_lock_owner (lock_info_type *owner, Lisp_Object lfname)
496 return ANOTHER_OWNS_IT; 496 return ANOTHER_OWNS_IT;
497 } 497 }
498 498
499 /* The owner process is dead or has a strange pid. 499 /* The owner process is dead or has a strange pid, or the lock file is empty.
500 Try to zap the lockfile. */ 500 Try to zap the lockfile. If the lock file is empty, this assumes
501 the file system is buggy, e.g., <https://bugs.gnu.org/72641>.
502 Emacs never creates empty lock files even temporarily, so removing
503 an empty lock file should be harmless. */
501 return emacs_unlink (SSDATA (lfname)) < 0 ? errno : 0; 504 return emacs_unlink (SSDATA (lfname)) < 0 ? errno : 0;
502} 505}
503 506