2

My initial quest is Can emacs on Mac using native window system connect to an emacs server on a Linux system but I got off on a tangent that might work ok but I hit a speed bump.

As described in the other question, I start emacs in daemon mode via the systemd script on Ubuntu.

I download and start XQuest and reboot my system. Now, every shell has DISPLAY set to a local socket. ssh -Y xxx works as expected causing the display to be on my Mac but inside XQuatz (X11). Fine... this is looking promising (although not my original goal).

Then the speed bump -- which I've hit long long ago.

If I do (from my Mac) ssh -Y xxyyzz /usr/bin/emacsclient -f server -c, I get an X11 window on my Mac connected to the server on xxyyzz. If I ^C the ssh, the window dies -- fine. But the emacs daemon also dies taking along with it any shells running within it.

This quest is to prevent the emacs daemon from dying when the display socket abruptly closes. I've tried setting debug-on-error, debug-on-quit, debug-on-signal but the daemon still exits. No message ... nothing.

I also connect to the same emacs daemon from a terminal local to the Ubuntu server. I thought I could see a message or something but no luck. When I ^C the ssh job, the terminal goes back to the command prompt with the terminal still in raw mode so I have to do ^Jreset^J to get the terminal back to a sane state again.

So... I thought I would try to debug this with gdb. Stopped the systemd service. Did gdb /usr/bin/emacs and then run --daemon but then I hit another problem because emacs detaches and gdb doesn't catch the error. As a sub-quest of this 2nd quest -- how can I get emacs in daemon mode not to detach? Or... perhaps I can tell gdb (I don't use gdb much -- sorry) to also debug the detached forks?

This may be a duplicate of emacs --daemon crashes when parent ssh session dies

1
  • 1
    At least for your last problem: use --fg-daemon in order not to detach
    – rpluim
    Commented Jul 8, 2019 at 10:17

1 Answer 1

3

The answer to the question is to use the Lucid version of emacs. With Ubuntu, the package is called emacs25-lucid. From comments in the code and it also pops out on stderr if you can managed to get it:

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",

The GTK bug is 17 years old.

I tried very briefly to comment out the code that aborts in this situation but emacs still died and I didn't chase it any further. The GTK bug report is still open and there is an update to it about every 6 months but it looks rather bleak for it being fixed any time.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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