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

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 68799 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca, jasonr <at> gnu.org
Subject: Re: bug#68799: 30.0.50; emacs --fg-daemon fails silently if
 server-start fails
Date: Tue, 13 Feb 2024 15:20:21 -0500
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Cc: 68799 <at> debbugs.gnu.org,  monnier <at> iro.umontreal.ca,  jasonr <at> gnu.org
>> Date: Tue, 13 Feb 2024 15:02:00 -0500
>> 
>> > I think your patch will prevent us from doing that because the code
>> > which you suggest to patch with DAEMON_RUNNING will kill Emacs before
>> > startup.el gets the chance to show the error message, because
>> > daemon-initialized has not yet been run by that time.
>> 
>> Nope, it won't prevent us from doing that.  My patch affects only
>> *uncaught* errors, and improves behavior when errors are uncaught.  The
>> separate change we will make to the code you posted is to *catch more
>> errors*.  A change to the behavior for uncaught errors doesn't interfere
>> with us deciding to catch more errors.  Defining an explicit error
>> handler, of course, completely overrides the default handle for uncaught
>> errors.  So they're totally separate patches.
>
> Then let's see them together, so we understand what happens in each
> and every case.  This bug started from a silent failure to start the
> server, so its solution should solve at least that.

To be clear, the patch I posted which checks DAEMON_RUNNING *does* solve
that.

$ ./src/emacs -Q --fg-daemon=/tmp/foo
Starting Emacs daemon.
‘/tmp’ is not a safe directory because it is not owned by you (owner = root (0))
$ 

(which previously would have hung)

The issue now is solely that the printed error message is maybe not
informative enough.

So how about the following diff, which changes the output to:

$ ./src/emacs -Q --fg-daemon=/tmp/foo
Starting Emacs daemon.
Unable to start daemon: ‘/tmp’ is not a safe directory because it is not owned by you (owner = root (0))
$ 

diff --git a/lisp/startup.el b/lisp/startup.el
index 773765a4b97..d1420a3f9c5 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1627,7 +1627,9 @@ command-line
   (let ((dn (daemonp)))
     (when dn
       (when (stringp dn) (setq server-name dn))
-      (server-start)
+      (condition-case err
+          (server-start)
+        (error (error "Unable to start daemon: %s" (error-message-string err))))
       (if server-process
 	  (daemon-initialized)
 	(if (stringp dn)




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.