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 #20 received at 68799 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Cc: 68799 <at> debbugs.gnu.org
>> Date: Mon, 29 Jan 2024 12:32:00 -0500
>>
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>> >> 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.
>> >
>> > Or maybe server-start signals an error, and then the code which shows
>> > an error message and shuts down Emacs doesn't get run?
>>
>> Yes, that's exactly what happens.
>>
>> So should we wrap a condition-case around server-start, I suppose?
>
> Probably. But perhaps we should also modify server-start so that,
> when it is called from a daemon, it signals in this case a distinct
> error, which startup.el could then detect and display a friendly error
> message.
Actually, it seems that main() already does a
fputs ("Error: server did not start correctly\n", stderr);
if the server process exits non-zero. So we already get a nice:
Starting Emacs daemon.
Creating directory: Permission denied, /nonexistent
Error: server did not start correctly
So I think the below patch suffices.
[0001-Message-when-server-start-errors-in-emacs-daemon.patch (text/x-patch, inline)]
From 2a6f039663a678d0fcae47318011fbb5d8bb5f1c Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh <at> janestreet.com>
Date: Mon, 29 Jan 2024 13:11:47 -0500
Subject: [PATCH] Message when server-start errors in emacs --daemon
Previously, if a user invoked emacs --daemon and then server-start
failed, there would be no indication of this and emacs would simply
hang.
Now, something like emacs --daemon=/nonexistent/sock results in:
$ emacs --fg-daemon=/nonexistent/sock
Starting Emacs daemon.
Creating directory: Permission denied, /nonexistent
$ emacs --daemon=/nonexistent/sock
Starting Emacs daemon.
Creating directory: Permission denied, /nonexistent
Error: server did not start correctly
and Emacs exits non-zero.
* lisp/startup.el (command-line): Catch errors from server-start, and
message and exit. (bug#68799)
---
lisp/startup.el | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lisp/startup.el b/lisp/startup.el
index 23937055f30..ae465b5bb07 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1627,7 +1627,11 @@ command-line
(let ((dn (daemonp)))
(when dn
(when (stringp dn) (setq server-name dn))
- (server-start)
+ (condition-case err
+ (server-start)
+ (error
+ (message "%s" (error-message-string err))
+ (kill-emacs 1)))
(if server-process
(daemon-initialized)
(if (stringp dn)
--
2.39.3
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.