unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#56800: Pointless "Warning: desktop file appears to be in use by PID ###."
@ 2022-07-27 16:25 Paul Pogonyshev
  2022-07-27 16:49 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Pogonyshev @ 2022-07-27 16:25 UTC (permalink / raw)
  To: 56800

[-- Attachment #1: Type: text/plain, Size: 837 bytes --]

GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.33,
cairo version 1.16.0) of 2022-07-26

Practically every time I start up Emacs, I get this pointless warning and a
question if I really want to use the desktop file anyway. If there were
actually another Emacs running, this warning would be fine, even useful.
However, in 95% of cases here it happens because computer was shut down,
Emacs crashed etc. In fact, I have just now verified that even if I cleanly
`M-x kill-emacs RET' my Emacs and then start a new one, the new still
thinks that the old, killed Emacs might still be using the desktop file
somehow (i.e. PID is that of the previous Emacs process).

The code in `desktop.el' should really check if the process with that PID
still exists before claiming that it might be using the desktop file
somehow.

Paul

[-- Attachment #2: Type: text/html, Size: 939 bytes --]

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

* bug#56800: Pointless "Warning: desktop file appears to be in use by PID ###."
  2022-07-27 16:25 bug#56800: Pointless "Warning: desktop file appears to be in use by PID ###." Paul Pogonyshev
@ 2022-07-27 16:49 ` Eli Zaretskii
  2022-07-27 16:58   ` Paul Pogonyshev
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2022-07-27 16:49 UTC (permalink / raw)
  To: Paul Pogonyshev; +Cc: 56800

> From: Paul Pogonyshev <pogonyshev@gmail.com>
> Date: Wed, 27 Jul 2022 18:25:24 +0200
> 
> The code in `desktop.el' should really check if the process with that PID still exists before claiming that it
> might be using the desktop file somehow.

AFAIU, you should be able to have that if you customize
desktop-load-locked-desktop to give it the value 'check-pid'.  Did you
try that?





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

* bug#56800: Pointless "Warning: desktop file appears to be in use by PID ###."
  2022-07-27 16:49 ` Eli Zaretskii
@ 2022-07-27 16:58   ` Paul Pogonyshev
  2022-07-27 17:32     ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Pogonyshev @ 2022-07-27 16:58 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 56800

[-- Attachment #1: Type: text/plain, Size: 778 bytes --]

No, but I have tried now. I guess I understand the default behavior better
now (even if I don't find it generally useful enough to be the default; how
many users really have remotely mounted paths in `desktop-dirname'?).

But why does even cleanly exiting Emacs leave desktop file "apparently
used"?

Paul

On Wed, 27 Jul 2022 at 18:50, Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Paul Pogonyshev <pogonyshev@gmail.com>
> > Date: Wed, 27 Jul 2022 18:25:24 +0200
> >
> > The code in `desktop.el' should really check if the process with that
> PID still exists before claiming that it
> > might be using the desktop file somehow.
>
> AFAIU, you should be able to have that if you customize
> desktop-load-locked-desktop to give it the value 'check-pid'.  Did you
> try that?
>

[-- Attachment #2: Type: text/html, Size: 1233 bytes --]

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

* bug#56800: Pointless "Warning: desktop file appears to be in use by PID ###."
  2022-07-27 16:58   ` Paul Pogonyshev
@ 2022-07-27 17:32     ` Eli Zaretskii
  2022-07-27 17:52       ` Paul Pogonyshev
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2022-07-27 17:32 UTC (permalink / raw)
  To: Paul Pogonyshev; +Cc: 56800

> From: Paul Pogonyshev <pogonyshev@gmail.com>
> Date: Wed, 27 Jul 2022 18:58:36 +0200
> Cc: 56800@debbugs.gnu.org
> 
> But why does even cleanly exiting Emacs leave desktop file "apparently used"?

It shouldn't, and it doesn't here.  Something I hope you will look
into and tell what you found.





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

* bug#56800: Pointless "Warning: desktop file appears to be in use by PID ###."
  2022-07-27 17:32     ` Eli Zaretskii
@ 2022-07-27 17:52       ` Paul Pogonyshev
  2022-07-27 18:58         ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Pogonyshev @ 2022-07-27 17:52 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 56800

[-- Attachment #1: Type: text/plain, Size: 1222 bytes --]

Yeah, apparently `kill-emacs' is considered "low-level primitive":

    Functions to call with no arguments to query about killing Emacs.
    If any of these functions returns nil, killing Emacs is canceled.
    ‘save-buffers-kill-emacs’ calls these functions, but ‘kill-emacs’,
    the low level primitive, does not.  See also ‘kill-emacs-hook’.

Since I have rebound C-x C-c for my private use (why waste such a nice
shortcut on something used once in a few days?), I have been using
`kill-emacs'. But apparently it's not what should be used... Emacs making
it easy to silently break things, nothing new.

I suggest that `desktop-release-lock' call is still moved from something
hooked on `kill-emacs-query-functions' to `kill-emacs-hook'. That part is
supposed to be done unconditionally.

Paul

On Wed, 27 Jul 2022 at 19:32, Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Paul Pogonyshev <pogonyshev@gmail.com>
> > Date: Wed, 27 Jul 2022 18:58:36 +0200
> > Cc: 56800@debbugs.gnu.org
> >
> > But why does even cleanly exiting Emacs leave desktop file "apparently
> used"?
>
> It shouldn't, and it doesn't here.  Something I hope you will look
> into and tell what you found.
>

[-- Attachment #2: Type: text/html, Size: 1798 bytes --]

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

* bug#56800: Pointless "Warning: desktop file appears to be in use by PID ###."
  2022-07-27 17:52       ` Paul Pogonyshev
@ 2022-07-27 18:58         ` Eli Zaretskii
  2022-07-27 19:22           ` Paul Pogonyshev
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2022-07-27 18:58 UTC (permalink / raw)
  To: Paul Pogonyshev; +Cc: 56800

> From: Paul Pogonyshev <pogonyshev@gmail.com>
> Date: Wed, 27 Jul 2022 19:52:31 +0200
> Cc: 56800@debbugs.gnu.org
> 
> Yeah, apparently `kill-emacs' is considered "low-level primitive":
> 
>     Functions to call with no arguments to query about killing Emacs.
>     If any of these functions returns nil, killing Emacs is canceled.
>     ‘save-buffers-kill-emacs’ calls these functions, but ‘kill-emacs’,
>     the low level primitive, does not.  See also ‘kill-emacs-hook’.
> 
> Since I have rebound C-x C-c for my private use (why waste such a nice shortcut on something used once
> in a few days?), I have been using `kill-emacs'. But apparently it's not what should be used... Emacs making
> it easy to silently break things, nothing new.
> 
> I suggest that `desktop-release-lock' call is still moved from something hooked on
> `kill-emacs-query-functions' to `kill-emacs-hook'. That part is supposed to be done unconditionally.

That change was made because the hook can ask questions, which doesn't
work in a daemon session.  So we moved the hook.





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

* bug#56800: Pointless "Warning: desktop file appears to be in use by PID ###."
  2022-07-27 18:58         ` Eli Zaretskii
@ 2022-07-27 19:22           ` Paul Pogonyshev
  2022-07-28  6:17             ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Pogonyshev @ 2022-07-27 19:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 56800


[-- Attachment #1.1: Type: text/plain, Size: 1406 bytes --]

I meant something like what is in the attached patch. The problem is that
_everything_ got moved to `...-query-functions', including that part that
has nothing to do with querying.

Paul



On Wed, 27 Jul 2022 at 20:58, Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Paul Pogonyshev <pogonyshev@gmail.com>
> > Date: Wed, 27 Jul 2022 19:52:31 +0200
> > Cc: 56800@debbugs.gnu.org
> >
> > Yeah, apparently `kill-emacs' is considered "low-level primitive":
> >
> >     Functions to call with no arguments to query about killing Emacs.
> >     If any of these functions returns nil, killing Emacs is canceled.
> >     ‘save-buffers-kill-emacs’ calls these functions, but ‘kill-emacs’,
> >     the low level primitive, does not.  See also ‘kill-emacs-hook’.
> >
> > Since I have rebound C-x C-c for my private use (why waste such a nice
> shortcut on something used once
> > in a few days?), I have been using `kill-emacs'. But apparently it's not
> what should be used... Emacs making
> > it easy to silently break things, nothing new.
> >
> > I suggest that `desktop-release-lock' call is still moved from something
> hooked on
> > `kill-emacs-query-functions' to `kill-emacs-hook'. That part is supposed
> to be done unconditionally.
>
> That change was made because the hook can ask questions, which doesn't
> work in a daemon session.  So we moved the hook.
>

[-- Attachment #1.2: Type: text/html, Size: 1984 bytes --]

[-- Attachment #2: 0001-Followup-to-5bd04ea307-still-have-M-x-kill-emacs-rel.patch --]
[-- Type: text/x-patch, Size: 1569 bytes --]

From e738c06312ce32f92acd62cdad9d8342451bd734 Mon Sep 17 00:00:00 2001
From: Paul Pogonyshev <pogonyshev@gmail.com>
Date: Wed, 27 Jul 2022 21:20:55 +0200
Subject: [PATCH] Followup to 5bd04ea307: still have `M-x kill-emacs' release
 desktop lock

---
 lisp/desktop.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lisp/desktop.el b/lisp/desktop.el
index 850d2a86ef..a0931e053e 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -791,7 +791,10 @@ desktop-clear
 
 ;; ----------------------------------------------------------------------------
 (unless noninteractive
-  (add-hook 'kill-emacs-query-functions #'desktop-kill))
+  (add-hook 'kill-emacs-query-functions #'desktop-kill)
+  ;; Certain things should be done even if
+  ;; `kill-emacs-query-functions' are not called.
+  (add-hook 'kill-emacs-hook #'desktop--on-kill))
 
 (defun desktop-kill ()
   "If `desktop-save-mode' is non-nil, do what `desktop-save' says to do.
@@ -818,12 +821,15 @@ desktop-kill
       (file-error
        (unless (yes-or-no-p "Error while saving the desktop.  Ignore? ")
 	 (signal (car err) (cdr err))))))
+  (desktop--on-kill)
+  t)
+
+(defun desktop--on-kill ()
   ;; If we own it, we don't anymore.
   (when (eq (emacs-pid) (desktop-owner))
     ;; Allow exiting Emacs even if we can't delete the desktop file.
     (ignore-error 'file-error
-      (desktop-release-lock)))
-  t)
+      (desktop-release-lock))))
 
 ;; ----------------------------------------------------------------------------
 (defun desktop-list* (&rest args)
-- 
2.35.1


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

* bug#56800: Pointless "Warning: desktop file appears to be in use by PID ###."
  2022-07-27 19:22           ` Paul Pogonyshev
@ 2022-07-28  6:17             ` Eli Zaretskii
  0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2022-07-28  6:17 UTC (permalink / raw)
  To: Paul Pogonyshev; +Cc: 56800-done

> From: Paul Pogonyshev <pogonyshev@gmail.com>
> Date: Wed, 27 Jul 2022 21:22:46 +0200
> Cc: 56800@debbugs.gnu.org
> 
> I meant something like what is in the attached patch. The problem is that _everything_ got moved to
> `...-query-functions', including that part that has nothing to do with querying.

Thanks, installed on the emacs-28 release branch.





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

end of thread, other threads:[~2022-07-28  6:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-27 16:25 bug#56800: Pointless "Warning: desktop file appears to be in use by PID ###." Paul Pogonyshev
2022-07-27 16:49 ` Eli Zaretskii
2022-07-27 16:58   ` Paul Pogonyshev
2022-07-27 17:32     ` Eli Zaretskii
2022-07-27 17:52       ` Paul Pogonyshev
2022-07-27 18:58         ` Eli Zaretskii
2022-07-27 19:22           ` Paul Pogonyshev
2022-07-28  6:17             ` Eli Zaretskii

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).