GNU bug report logs - #68799
30.0.50; emacs --fg-daemon fails silently if server-start fails

Previous Next

Package: emacs;

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 #44 received at 68799 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: 68799 <at> debbugs.gnu.org
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, Jason Rumney <jasonr <at> gnu.org>
Subject: Re: bug#68799: 30.0.50; emacs --fg-daemon fails silently if
 server-start fails
Date: Mon, 12 Feb 2024 17:10:34 -0500
Spencer Baugh <sbaugh <at> janestreet.com> writes:
> 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.

Okay, I found what one might call the root cause, the following code and
comment.  Adding Stefan and Jason to CC as the original authors.

/* The initial frame is a special non-displaying frame. It
   will be current in daemon mode when there are no frames
   to display, and in non-daemon mode before the real frame
   has finished initializing.  If an error is thrown in the
   latter case while creating the frame, then the frame
   will never be displayed, so the safest thing to do is
   write to stderr and quit.  In daemon mode, there are
   many other potential errors that do not prevent frames
   from being created, so continuing as normal is better in
   that case.  */
|| (!IS_DAEMON && FRAME_INITIAL_P (sf))

The comment is mostly sensible: we should exit while initializing, and
shouldn't exit while in the steady state of daemon mode.

However, it doesn't handle the case when Emacs is initializing *and* in
daemon mode.  In that case, an error will prevent frames from being
created, just like in non-daemon mode.

So this check really wants to be something more like:
|| ( IS_DAEMON && [something to check if Emacs is starting up])
|| (!IS_DAEMON && FRAME_INITIAL_P (sf))

Not sure what [something to check if Emacs is starting up] should be
though.  Maybe it should check that server-process is non-nil and alive?
That would be pretty nice, because then an error which stops the server
would cause the Emacs daemon to log the error to stderr - and otherwise
there's no way to get the error message from such an error.




This bug report was last modified 1 year and 86 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.