all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* how to cleanly stop emacs daemon from commandline?
@ 2016-10-02  2:49 Tom Roche
  2016-10-02  3:31 ` Tom Roche
  2016-10-02  8:45 ` Eli Zaretskii
  0 siblings, 2 replies; 3+ messages in thread
From: Tom Roche @ 2016-10-02  2:49 UTC (permalink / raw)
  To: help-gnu-emacs


[endnotes after .sig]

summary: I have tried several variations of

$ emacsclient -e '(your-elisp-here)'

and have found none that would cause a running `emacs --daemon` process (EDP) to stop "cleanly" as defined by T.V. Raman (below):

1. release all locks (I have tested only desktop lock)
2. stop (e.g., such that `pgrep -l emacs` no longer shows its PID)

Is there no way to do this? Conversely, is the EDP designed to run until brutally whacked? (with, e.g., `kill -9 ${PID}`)

details:

This seems to be a longstanding request, as a nearly similar thread[1] is almost 5 years old:

From: T. V. Raman
To: emacs-devel@ gnu.org
Subject: HowTo: quit an emacs --daemon
Date: Tue, 22 Nov 2011 19:43:34 -0800

> quitting out of all emacsclient sessions still
> keeps the daemon around -- and killing that process feels crude

e.g., `kill -9 ${PID}` or `pkill -9 emacs`

> -- it then leaves files like the emacs.desktop file locked. Is
> there a clean way of asking a running emacs --daemon process to quit?

but IIRC similar posts go back to 2009. My situation is similar, except that I'm re/starting my daemon as part of porting my Emacs config to a new base (details here[2]). My verification process is

0. Exit Emacs client if in one (`C-x C-c`)
1. Move to a bash shell for all subsequent steps
2. Check EDP (et al) and desktop lockfile(s) with the following bash oneliner:

date ; pgrep -l emacs ; find ~/ -maxdepth 1 -type d -name '.emacs.d_*' | xargs -i find {} -type f -name '*lock'

3. Run the emacsclient oneliner under test (see below)
4. Recheck with bash oneliner

In no case have I found an emacsclient oneliner (or any other shell command) that is 'clean' as defined by Dr Raman. I have tried numerous substitutions for '(your-elisp-here)', including

1. (kill-emacs): often recommended, but I do not observe either the EDP to stop or desktop lockfile to be removed after running `emacsclient -e '(kill-emacs)'`

2. (save-buffers-kill-emacs): ditto

3. (save-buffers-kill-terminal): ditto

4. As recommended here[3], I tried adding

(defun tv-stop-emacs ()
  (interactive)
  (if (daemonp)
      (save-buffers-kill-emacs)
      (save-buffers-kill-terminal)))

   to my Emacs config, then `eval-region`, but running `emacsclient -e '(tv-stop-emacs)'` from the commandline failed the above test procedure.

5. (run-with-timer 0 0 'save-buffers-kill-emacs): recommended here[4], but gives error=

> *ERROR*: Invalid repetition interval

   By contrast, `(run-with-timer 0 1 'save-buffers-kill-emacs)` just fails to work as claimed.

I'm fairly sure I have tried other emacsclient oneliners that I have forgotten (as minor variations on the above). It seems odd that lotsa folks believe this can be done, but nothing I've found seems to work. Am I missing something? If this usecase *is* working for OP, how to debug my situation?

platform:

Kinda vanilla, slightly downlevel but I wanna fix something before I upgrade my kernel, and I wanted to update my Emacs config in order to pull in some tools that I wanted to use in order to fix it :-(

$ date
Sat Oct  1 19:01:14 MST 2016
$ uname -rsv
Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02)
$ lsb_release -ds
LMDE 2 Betsy
$ cat /etc/debian_version
8.5
$ gcc --version | head -n 1
gcc (Debian 4.9.2-10) 4.9.2
$ emacs --version | head -1
GNU Emacs 24.4.1

your assistance is appreciated, Tom Roche <Tom_Roche@pobox.com>

[1]: https://lists.gnu.org/archive/html/emacs-devel/2011-11/msg00342.html
[2]: http://emacs.stackexchange.com/q/27376/5444
[3]: https://lists.gnu.org/archive/html/emacs-devel/2011-11/msg00348.html
[4]: https://lists.gnu.org/archive/html/help-gnu-emacs/2009-08/msg00757.html



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

end of thread, other threads:[~2016-10-02  8:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-02  2:49 how to cleanly stop emacs daemon from commandline? Tom Roche
2016-10-02  3:31 ` Tom Roche
2016-10-02  8:45 ` Eli Zaretskii

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.