unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* emacs server or daemon mode
@ 2019-07-07 21:00 Perry Smith
  2019-07-08 23:44 ` Perry Smith
  0 siblings, 1 reply; 2+ messages in thread
From: Perry Smith @ 2019-07-07 21:00 UTC (permalink / raw)
  To: help-gnu-emacs

My laptop is a Mac running the latest.  I have an Ubuntu machine running 18.04.  The Mac has emacs 26.1 that I built myself although at this point, its completely out of the picture.  The Ubuntu machine now has emacs 26.2 built by “KelleyK”.  I also have the latest XQuatz on the Mac.  XQuarts is an X11 port to the Mac.

On the Ubuntu machine, my .emacs.d/init.el looks like this:

(setq
 server-log t
 server-host "192.168.1.104"
 server-port "9999"
 server-use-tcp t)

And I have enabed and started the systemd emacs.server (after slight editing) which now looks like this:

## If your Emacs is installed in a non-standard location, you may need
## to copy this file to a standard directory, eg ~/.config/systemd/user/ .
## If you install this file by hand, change the "Exec" lines below
## to use absolute file names for the executables.
[Unit]
Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/

[Service]
Type=simple
ExecStart=/usr/bin/emacs26 --fg-daemon
ExecStop=/usr/bin/emacsclient26 --eval "(kill-emacs)"
Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Restart=on-failure

[Install]
WantedBy=default.target

On my Mac, I execute a command such as this (I’ve tried many variations):

ssh -Y crystal /usr/bin/emacsclient26 -f server -c

An X11 window pops up on my Mac display.  For those who are not familiar, after installing XQuarts, the terminals have a DISPLAY set to a local socket.  The ssh -Y propagates this to the other side and that is the socket that emacsclient is using to get back to my local display.  All appears good.  There is usually (not always) a message that says ^X 5 0 to close the window.  I type this and the window disappears but the ssh does not exit.

When I ^C the ssh, the emacs daemon on the Ubuntu host dies (and is restarted by systemd).

One quest is to make the daemon not die even if the disconnect is abrupt but I can’t even find a way to gracefully exit or disconnect such that the ssh exits.  The goal in this case is to use the Ubuntu machine and I’d like the build and the shell buffers that contain the build to survive a disconnect (graceful or abrupt).

As you can see from my init file, I’ve tried getting the server log but the buffer is not created.

Another tactic I’ve tried is to not only connect to the Ubuntu emacs server via the Mac but also ssh over and connect to it by running 

emacsclient26 -f server -nw

from the prompt on the Ubuntu machine.  From that terminal I do various things like print out server-clients … often it is correct but almost equally as often its not — showing fewer clients than are actually present.  I show the buffers but there are only two *scratch* and *Messages* … no server log.

With the ssh -Y emacsclient ..., I’ve tried -f and -t and with emacsclient I’ve tried -n.  I’ve also tried redirecting stdin, stdout, and stderr to /dev/null or close them via <&-, etc.

I’ve also tried removing the init.el file shown above.  I was originally trying to do something different and wanted to use a TCP socket but at this point, that is no longer a requirement.

I assume I must be doing something fundamentally wrong so I came to this group looking for help rather than the bug group.

Thank you for your help,
Perry



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

* Re: emacs server or daemon mode
  2019-07-07 21:00 emacs server or daemon mode Perry Smith
@ 2019-07-08 23:44 ` Perry Smith
  0 siblings, 0 replies; 2+ messages in thread
From: Perry Smith @ 2019-07-08 23:44 UTC (permalink / raw)
  To: help-gnu-emacs

Curious that no one replied to my original post.  I tracked down one issue of why emacs aborts when the X11 connection closes.  Its due to this:

> #ifdef USE_GTK
>       /* A long-standing GTK bug prevents proper disconnect handling
> 	 (https://bugzilla.gnome.org/show_bug.cgi?id=85715).  Once,
> 	 the resulting Glib error message loop filled a user's disk.
> 	 To avoid this, kill Emacs unconditionally on disconnect.  */
>       shut_down_emacs (0, Qnil);
>       fprintf (stderr, "%s\n\
> When compiled with GTK, Emacs cannot recover from X disconnects.\n\
> This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715\n\
> For details, see etc/PROBLEMS.\n",
> 	       error_msg);
>       emacs_abort ();
> #endif /* USE_GTK */

As a test, I commented that code and but emacs still dies.  I didn’t track it any further.  Instead I switched to “Lucid” and the crash doesn’t happen.

If you look at the GTK bug report, it seems every six months or so another Emacs uses bumps into the same issue.

The server-log and other issues I bumped into I probably won’t chase down.

Perry


> On Jul 7, 2019, at 4:00 PM, Perry Smith <pedz@easesoftware.com> wrote:
> 
> My laptop is a Mac running the latest.  I have an Ubuntu machine running 18.04.  The Mac has emacs 26.1 that I built myself although at this point, its completely out of the picture.  The Ubuntu machine now has emacs 26.2 built by “KelleyK”.  I also have the latest XQuatz on the Mac.  XQuarts is an X11 port to the Mac.
> 
> On the Ubuntu machine, my .emacs.d/init.el looks like this:
> 
> (setq
>  server-log t
>  server-host "192.168.1.104"
>  server-port "9999"
>  server-use-tcp t)
> 
> And I have enabed and started the systemd emacs.server (after slight editing) which now looks like this:
> 
> ## If your Emacs is installed in a non-standard location, you may need
> ## to copy this file to a standard directory, eg ~/.config/systemd/user/ .
> ## If you install this file by hand, change the "Exec" lines below
> ## to use absolute file names for the executables.
> [Unit]
> Description=Emacs text editor
> Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
> 
> [Service]
> Type=simple
> ExecStart=/usr/bin/emacs26 --fg-daemon
> ExecStop=/usr/bin/emacsclient26 --eval "(kill-emacs)"
> Environment=SSH_AUTH_SOCK=%t/keyring/ssh
> Restart=on-failure
> 
> [Install]
> WantedBy=default.target
> 
> On my Mac, I execute a command such as this (I’ve tried many variations):
> 
> ssh -Y crystal /usr/bin/emacsclient26 -f server -c
> 
> An X11 window pops up on my Mac display.  For those who are not familiar, after installing XQuarts, the terminals have a DISPLAY set to a local socket.  The ssh -Y propagates this to the other side and that is the socket that emacsclient is using to get back to my local display.  All appears good.  There is usually (not always) a message that says ^X 5 0 to close the window.  I type this and the window disappears but the ssh does not exit.
> 
> When I ^C the ssh, the emacs daemon on the Ubuntu host dies (and is restarted by systemd).
> 
> One quest is to make the daemon not die even if the disconnect is abrupt but I can’t even find a way to gracefully exit or disconnect such that the ssh exits.  The goal in this case is to use the Ubuntu machine and I’d like the build and the shell buffers that contain the build to survive a disconnect (graceful or abrupt).
> 
> As you can see from my init file, I’ve tried getting the server log but the buffer is not created.
> 
> Another tactic I’ve tried is to not only connect to the Ubuntu emacs server via the Mac but also ssh over and connect to it by running 
> 
> emacsclient26 -f server -nw
> 
> from the prompt on the Ubuntu machine.  From that terminal I do various things like print out server-clients … often it is correct but almost equally as often its not — showing fewer clients than are actually present.  I show the buffers but there are only two *scratch* and *Messages* … no server log.
> 
> With the ssh -Y emacsclient ..., I’ve tried -f and -t and with emacsclient I’ve tried -n.  I’ve also tried redirecting stdin, stdout, and stderr to /dev/null or close them via <&-, etc.
> 
> I’ve also tried removing the init.el file shown above.  I was originally trying to do something different and wanted to use a TCP socket but at this point, that is no longer a requirement.
> 
> I assume I must be doing something fundamentally wrong so I came to this group looking for help rather than the bug group.
> 
> Thank you for your help,
> Perry
> 




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

end of thread, other threads:[~2019-07-08 23:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-07 21:00 emacs server or daemon mode Perry Smith
2019-07-08 23:44 ` Perry Smith

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