0

With GNU Emacs 23.2.1, that I installed from sources on 2 different GNU/Linux distributions (CentOS 4.x, and Ubuntu Hardy - both with KDE 3.x)

I do:

$ emacs --daemon
("emacs")
Starting Emacs daemon.
$ emacsclient -c
Waiting for Emacs...

Emacs starts as expected. Then I close the client. fuser /tmp/emacs${UID}/server indicates that the socket is alive, and the emacs --daemon process is running.

$ emacsclient -c
Waiting for Emacs...

Emacs does not start. fuser /tmp/emacs${UID}/server indicates that the socket is stale, and the emacs --daemon process no longer exists. And so:

$ emacsclient -c
emacsclient: connect: Connection refused
emacsclient: No socket or alternate editor.  Please use:

        --socket-name
        --server-file      (or environment variable EMACS_SERVER_FILE)
        --alternate-editor (or environment variable ALTERNATE_EDITOR)

When I keep at least one client running, I can open and close as many other clients I wish.

So my questions are:

  1. Can anybody else see this behavior?
  2. Is there a way to keep the socket alive even after the last client exits?
  3. Is there a good way to check if the socket will allow opening another client?
  4. Why does the socket stays around if it can no longer be used?

Edit: It seems that emacs --daemon segfaults. I posted it as bug 7149

2 Answers 2

1

Can anybody else see this behavior?

Yes, though my working style is different. I have (server-start) in my .emacs file instead of using command line arguments.

Is there a way to keep the socket alive even after the last client exits?

Are you using C-x # to close client buffers cleanly?

Is there a way to keep the socket alive even after the last client exits?

I find that I have to M-x server-start on an Emacs that has been up for a couple of days or more. It is not exactly keeping it alive, but re-creating it.

Why does the socket stays around if it can no longer be used?

I believe this is a bug.

2
  • 1. Thanks for the confirmation; Can you please describe your work-flow beside using (server-start)? 2. No, but even if so, it does not seem to help. Nor exiting with C-x 5 0; 3. Don't thing it apply. 4. I'll check if this bug is reported.
    – Chen Levy
    Sep 30, 2010 at 19:07
  • The other half of my workflow is a bash alias for emacsclient that redirects I/O and puts emacsclient quietly into the background when launching the new buffer.
    – kmarsh
    Sep 30, 2010 at 20:46
0

I was able to overcome this problem by deleting the directory containing the socket. I ran:

strace emacsclient -c

and saw these lines:

stat("/tmp/emacs1000/server", {st_mode=S_IFSOCK|0700, st_size=0, ...}) = 0
connect(3, {sa_family=AF_FILE, path="/tmp/emacs1000/server"}, 23) = -1 ECONNREFUSED (Connection refused)

which show the directory where the socket file is located, then all I had to do was delete this directory:

rm -rf /tmp/emacs1000

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .