From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Pierre Neidhardt Newsgroups: gmane.emacs.bugs 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 Message-ID: <871shram2i.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1518343416 21889 195.159.176.226 (11 Feb 2018 10:03:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 11 Feb 2018 10:03:36 +0000 (UTC) User-Agent: mu4e 1.0; emacs 25.3.1 To: 30421@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Feb 11 11:03:32 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekoTg-0004k7-63 for geb-bug-gnu-emacs@m.gmane.org; Sun, 11 Feb 2018 11:03:20 +0100 Original-Received: from localhost ([::1]:42150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekoVh-0006xB-Nj for geb-bug-gnu-emacs@m.gmane.org; Sun, 11 Feb 2018 05:05:25 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekoLf-00067w-SV for bug-gnu-emacs@gnu.org; Sun, 11 Feb 2018 04:55:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekoLe-0001X4-Vy for bug-gnu-emacs@gnu.org; Sun, 11 Feb 2018 04:55:03 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57957) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ekoLe-0001Wu-SG for bug-gnu-emacs@gnu.org; Sun, 11 Feb 2018 04:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ekoLe-0006yH-M8 for bug-gnu-emacs@gnu.org; Sun, 11 Feb 2018 04:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Pierre Neidhardt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 11 Feb 2018 09:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 30421 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.151834287226755 (code B ref -1); Sun, 11 Feb 2018 09:55:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 Feb 2018 09:54:32 +0000 Original-Received: from localhost ([127.0.0.1]:37621 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekoLA-0006xS-5A for submit@debbugs.gnu.org; Sun, 11 Feb 2018 04:54:32 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:51311) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekoL8-0006xE-In for submit@debbugs.gnu.org; Sun, 11 Feb 2018 04:54:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekoL2-0000hh-G1 for submit@debbugs.gnu.org; Sun, 11 Feb 2018 04:54:25 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:51822) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ekoL2-0000hN-CM for submit@debbugs.gnu.org; Sun, 11 Feb 2018 04:54:24 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42238) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekoL0-0005Nk-Un for bug-gnu-emacs@gnu.org; Sun, 11 Feb 2018 04:54:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekoKz-0000cs-Qb for bug-gnu-emacs@gnu.org; Sun, 11 Feb 2018 04:54:23 -0500 Original-Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:40872) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ekoKz-0000aK-Js for bug-gnu-emacs@gnu.org; Sun, 11 Feb 2018 04:54:21 -0500 Original-Received: by mail-wm0-x231.google.com with SMTP id v123so4752044wmd.5 for ; Sun, 11 Feb 2018 01:54:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:date:message-id:mime-version; bh=l2h+w4CoAMHhpESjsiyGQuG/lJ74c5KfuhW9Tf+3iuE=; b=J0DcT06FlY9fFBTRVSW0Uv+ACzG6/p6eNoBIe5spzYbsjbKOU75Afa1lQn89o/cAaa jIZUQ1uu3k09uMg5vU7seKtWfrsdMGtCheRTbU60zOdGkPgjbPt8HTyjlI5LxCt2Hr6n yGwWA731apfb0UBlXrUiYe0SsGgQVN/3SROYk433Um65ZVZVLyFX2Dvk7cDKt5jheggI uAxghKA2/1lkNvkZpew/ttM7oMGdMBdNUJkfGKO5W4jQpO9l2PiS6mhdOvC33ZyfBZHY gumX0JErjBRTYjYGImei9htjtB1mCMIPTc9avVBSHsqGVb09mfvvKLq0STwli5vBmJzJ VVXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:date:message-id :mime-version; bh=l2h+w4CoAMHhpESjsiyGQuG/lJ74c5KfuhW9Tf+3iuE=; b=UUC4H5ghLpqWmSnJxB+CgBlQHvqsapSjhZkWpVqrdRLSrbnxIMgin25oxcxw+fWjT/ IQovlhP60T0//6Vtrof1RnC38DScmeaCVbbkWgWT2ULIDm9qWj5W86vl4hoqlvgCmxQQ lzt5/nM4/EzFV/n/CkAVjtbRhcYMhPzkbRWmVnYrE9ZRxo4Mq7wPyqdj9cQ+W9wA5fwQ ffZsFTpXO64Jgn4QXdTmh4PpkbC1EcZhrfyclZRme3dXsf/z1uV9p/snfmF2m2VPlrPz xog+8wzSdsIEzHnYUjuw2vwFPzFsH3ySJ3FIBBv3J1JbKUg6Z6faHXlownx9yZWe1pOU MrAw== X-Gm-Message-State: APf1xPDtgUN0nPKFWIQ3V/Vjx0josPjjXx7vlA/YtSKhtqo4Xc350YmZ Jp5zGc8mWbY4d/S8g9ECTufybA== X-Google-Smtp-Source: AH8x227Pb+0IMA8z5/sEfKPVWl1+2zYDx86orv6RBFrh1OtQuQr7wct/1w7yGx+KWjRPa5mUawx02Q== X-Received: by 10.28.218.12 with SMTP id r12mr842819wmg.157.1518342859949; Sun, 11 Feb 2018 01:54:19 -0800 (PST) Original-Received: from mimimi (2a01cb040a37a0003a915b0581181238.ipv6.abo.wanadoo.fr. [2a01:cb04:a37:a000:3a91:5b05:8118:1238]) by smtp.gmail.com with ESMTPSA id p14sm5775281wrg.42.2018.02.11.01.54.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Feb 2018 01:54:19 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:143131 Archived-At: 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