Subject: bug#18375: 24.4.50; Emacs hangs X session manager logout in certain cases

From: Stefan Monnier <[email-masked]>
Date: Tue, 02 Sep 2014 14:25:39 -0400

> I investigated a bit and think the reason has something to do with the
> way the SM communication is tied to the first opened terminal.

Your analysis makes a lot of sense.

> If I may add, the current behaviour is rather weird to begin with. The
> SM integration's purpose is to cleanly shutdown Emacs on logout, so it
> should be tied to the entire process and not to a particular terminal.

Indeed, we have a problem there.  The `emacs --daemon' is not tied to
a particular display, so it should not shutdown in response to such
SM events.  OTOH, many users use "emacs --daemon" only for their
current session.  So I can't think of any way to resolve this, short of
making it a config var, like in your patch.

Looking at your patch, I like the idea of exposing the session-start/end
to Elisp, but I know too little about this area to really review
your patch.  Could someone else take a look at it?

        Stefan