If Emacs or the system crashes when
desktop-save-mode is active, Emacs leaves a stale desktop lock file. The next time the desktop is loaded (from another Emacs process ID), loading is interrupted with a question:
Warning: desktop file appears to be in use by PID xxx.
Using it may cause conflicts. Use it anyway? (y or n)
even if if the process with PID xxx (substitute a process ID for xxx) is no longer alive.
Here is minimal example: First run
emacs -Q -l init.el with the following init file (
(require 'desktop) (let ((dir "/home/hakon/my-emacs-desktop-test")) (setq desktop-path (list dir)) (desktop-save-mode 1))
Then open some new buffers, and exit emacs. This will generate a new desktop file. Now, create a fake lock file (with process ID 999 or substitute any integer that does not represent a running process ID)
echo "999" > /home/hakon/my-emacs-desktop-test/.emacs.desktop.lock
and rerun Emacs with a new init file
emacs -Q -l init2.el, where
(require 'desktop) (let ((dir "/home/hakon/my-emacs-desktop-test")) (setq desktop-path (list dir)) (desktop-save-mode 1)) (desktop-read)
This should bring up the warning ("desktop file appears to be in use").
How can we get rid of this message?