unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#30421: 25.3; desktop.el: Steal lock when no living "emacs" process owns it
@ 2018-02-11  9:54 Pierre Neidhardt
  2018-02-11 15:50 ` Eli Zaretskii
  2018-02-11 20:40 ` Richard Stallman
  0 siblings, 2 replies; 28+ messages in thread
From: Pierre Neidhardt @ 2018-02-11  9:54 UTC (permalink / raw)
  To: 30421


By default, desktop-save-mode will not save (and will set
desktop-dirname to nil) if a lock file exists with a PID in it.

It's problematic however when Emacs gets killed and does not release the
lock.  Upon next start, desktop-save-mode will refuse to save because
the lock exists, even though no process is using it.  In terms of user
experience, it's pretty bad considering the error feedback is just one
line in the *Messages* buffer (I almost never notice it when it happens)
and the problem is persistent across reboots (the lock file will remain
as long as the user does not remove it manually).

Furthermore, isn't it strange to just check if there lock file contains
a number and not actually check if it's an existing PID?

I think it would make much more sense to actually check if the owner is
an _existing_ process named "emacs".

Here is my suggested patch:

	(defun desktop-owner (&optional dirname)
	  "Return the PID of the Emacs process that owns the desktop file in DIRNAME.
	Return nil if no desktop file found or no Emacs process is using it.
	DIRNAME omitted or nil means use `desktop-dirname'."
	  (let (owner
	        (file (desktop-full-lock-name dirname)))
	    (and (file-exists-p file)
	         (ignore-errors
	           (with-temp-buffer
	             (insert-file-contents-literally file)
	             (goto-char (point-min))
	             (setq owner (read (current-buffer)))
	             (integerp owner)
	+            (process-attributes owner)
	+            (string= "emacs" (alist-get 'comm (process-attributes owner)))))
	         owner)))



In GNU Emacs 25.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.26)
 of 2017-12-16 built on build
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description:	Void Linux

Configured using:
 'configure --with-x-toolkit=gtk3 --with-xwidgets --prefix=/usr
 --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
 --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var
 --with-file-notification=inotify --with-modules --with-jpeg --with-tiff
 --with-gif --with-png --with-xpm --with-rsvg --without-imagemagick
 --with-xml2 --with-gnutls --with-sound --with-m17n-flt
 --host=x86_64-unknown-linux-gnu --build=x86_64-unknown-linux-gnu
 'CFLAGS=-fno-PIE -mtune=generic -O2 -pipe -g' 'CPPFLAGS= '
 'LDFLAGS=-no-pie -Wl,--as-needed ''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND DBUS GSETTINGS NOTIFY ACL GNUTLS
LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11
MODULES XWIDGETS

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix





^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2018-03-19 13:09 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-11  9:54 bug#30421: 25.3; desktop.el: Steal lock when no living "emacs" process owns it Pierre Neidhardt
2018-02-11 15:50 ` Eli Zaretskii
2018-02-11 16:08   ` Pierre Neidhardt
2018-02-11 16:15     ` Noam Postavsky
2018-02-11 16:32       ` Eli Zaretskii
2018-02-11 16:57         ` Pierre Neidhardt
2018-02-11 17:18           ` Eli Zaretskii
2018-02-11 17:23             ` Pierre Neidhardt
2018-02-11 18:00               ` Eli Zaretskii
2018-02-11 18:41                 ` Pierre Neidhardt
2018-02-11 18:54                   ` Eli Zaretskii
2018-02-11 19:01                     ` Pierre Neidhardt
2018-02-15 22:56                       ` Pierre Neidhardt
2018-02-16  8:11                         ` Eli Zaretskii
2018-02-16 22:58                           ` Pierre Neidhardt
2018-02-17  7:43                             ` Eli Zaretskii
2018-02-18 11:26                               ` Pierre Neidhardt
2018-02-18 16:37                                 ` Eli Zaretskii
2018-02-24 10:39                                   ` Eli Zaretskii
2018-02-24 19:44                                     ` Pierre Neidhardt
2018-02-24 20:09                                       ` Eli Zaretskii
2018-03-03 11:33                                         ` Eli Zaretskii
2018-03-03 18:05                                           ` Pierre Neidhardt
2018-03-10 11:52                                             ` Eli Zaretskii
2018-03-19 11:06                                               ` Pierre Neidhardt
2018-03-19 12:47                                                 ` Eli Zaretskii
2018-03-19 13:09                                                   ` Pierre Neidhardt
2018-02-11 20:40 ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).