GNU bug report logs -
#68799
30.0.50; emacs --fg-daemon fails silently if server-start fails
Previous Next
Reported by: Spencer Baugh <sbaugh <at> janestreet.com>
Date: Mon, 29 Jan 2024 16:55:02 UTC
Severity: normal
Found in version 30.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 68799 <at> debbugs.gnu.org (full text, mbox):
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Date: Mon, 29 Jan 2024 11:54:21 -0500
>
>
> 1. emacs -Q --fg-daemon=/nonexistent/dir/sock
> 2. Emacs prints "Starting Emacs daemon." and sits in foreground.
> 3. emacsclient -c -s /nonexistent/dir/sock
> 4. emacsclient prints and exits:
> emacsclient: can't find socket; have you started the server?
> emacsclient: To start the server in Emacs, type "M-x server-start".
> emacsclient: error accessing socket "/nonexistent/dir/sock"
>
> This is because in step 1, the server actually failed to start, but
> Emacs did not log that at all. In fact, it's impossible to access the
> Emacs started in 1 now, since it's not actually running a server and it
> has no frames.
>
> The same thing happens with --bg-daemon, although it's slightly more
> obvious that something is wrong in that case, because --bg-daemon is not
> supposed to sit in foreground.
>
> Emacs with --fg-daemon should instead print an error and exit if it
> fails to start the server.
Have some faith in Emacs: we already do that. From startup.el:
(let ((dn (daemonp)))
(when dn
(when (stringp dn) (setq server-name dn))
(server-start)
(if server-process
(daemon-initialized)
(if (stringp dn)
(message
"Unable to start daemon: Emacs server named %S already running"
server-name)
(message "Unable to start the daemon.\nAnother instance of Emacs is running the server, either as daemon or interactively.\nYou can use emacsclient to connect to that Emacs process."))
(kill-emacs 1))))
So the problem seems to be that somehow server-start succeeds to leave
a non-nil server-process variable behind, although testing that is the
documented way of telling whether server is running.
So what is the value of server-process in your scenario?
This bug report was last modified 1 year and 87 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.