I am using emacs 24.3 (ubuntu 14.10) and would like the daemon to participate in the graphical desktop session lifecycle while using desktop-mode. I went through http://www.emacswiki.org/emacs/EmacsAsDaemon but it still does not play nice for me. One problem is that the daemon SIGTERM termination does not clean up .emacs.desktop.lock so the next start will refuse to pick up the saved state.

Does anyone have a recipe to make emacs daemon + desktop mode play nice with the graphical desktop session?

As a sidenote: Sending SIGHUP frequently crashes emacs for me.


Don't kill the process.

Use M-x kill-emacs RET to terminate the server.

| improve this answer | |
  • Ok, that cleans up the look. I may be missing something, but how does one execute that termination of the graphical session? The easiest thing I could think of would be a custom OS signal handler. – Andreas Steffan Feb 11 '15 at 10:13
  • 2
    If you have an active client frame, you can issue kill-emacs directly. If you have no current clients, you can run emacsclient -e '(kill-emacs)'. If you just want Emacs to shut down more gracefully when killed by a signal, you'll probably need to M-x report-emacs-bug (after checking to see whether it's already been logged). – phils Feb 11 '15 at 23:32
  • Sure. The thing is that I do not want to bother and manually tell every program to shut down gracefully. Desktop session managers do tell programs the session is about to terminate. I want emacs to automatically take action at that time. – Andreas Steffan Feb 12 '15 at 8:19
  • Well check the bug reports, report a new one if necessary, and once you have more information, update the question, or post an answer. – phils Feb 12 '15 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.