all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pierre Neidhardt <ambrevar@gmail.com>
To: 30421@debbugs.gnu.org
Subject: bug#30421: 25.3; desktop.el: Steal lock when no living "emacs" process owns it
Date: Sun, 11 Feb 2018 10:54:13 +0100	[thread overview]
Message-ID: <871shram2i.fsf@gmail.com> (raw)


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





             reply	other threads:[~2018-02-11  9:54 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-11  9:54 Pierre Neidhardt [this message]
2018-02-11 15:50 ` bug#30421: 25.3; desktop.el: Steal lock when no living "emacs" process owns it 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871shram2i.fsf@gmail.com \
    --to=ambrevar@gmail.com \
    --cc=30421@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.