all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Spencer Baugh <sbaugh@janestreet.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 68799@debbugs.gnu.org
Subject: bug#68799: 30.0.50; emacs --fg-daemon fails silently if server-start fails
Date: Mon, 29 Jan 2024 13:13:42 -0500	[thread overview]
Message-ID: <ierle886m95.fsf@janestreet.com> (raw)
In-Reply-To: <86v87c2fw4.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 29 Jan 2024 19:44:43 +0200")

[-- Attachment #1: Type: text/plain, Size: 1219 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:
>> From: Spencer Baugh <sbaugh@janestreet.com>
>> Cc: 68799@debbugs.gnu.org
>> Date: Mon, 29 Jan 2024 12:32:00 -0500
>> 
>> Eli Zaretskii <eliz@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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Message-when-server-start-errors-in-emacs-daemon.patch --]
[-- Type: text/x-patch, Size: 1406 bytes --]

From 2a6f039663a678d0fcae47318011fbb5d8bb5f1c Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@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


  reply	other threads:[~2024-01-29 18:13 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-29 16:54 bug#68799: 30.0.50; emacs --fg-daemon fails silently if server-start fails Spencer Baugh
2024-01-29 17:11 ` Eli Zaretskii
2024-01-29 17:18   ` Eli Zaretskii
2024-01-29 17:32     ` Spencer Baugh
2024-01-29 17:44       ` Eli Zaretskii
2024-01-29 18:13         ` Spencer Baugh [this message]
2024-01-29 19:12           ` Eli Zaretskii
2024-01-29 20:28             ` Spencer Baugh
2024-01-30 12:08               ` Eli Zaretskii
2024-02-10 19:50                 ` sbaugh
2024-02-10 20:05                   ` Eli Zaretskii
2024-02-10 23:23                     ` sbaugh
2024-02-11  7:24                       ` Eli Zaretskii
2024-02-12 22:10 ` Spencer Baugh
2024-02-13 12:35   ` Eli Zaretskii
2024-02-13 17:37     ` Spencer Baugh
2024-02-13 17:49       ` Eli Zaretskii
2024-02-13 18:04         ` Spencer Baugh
2024-02-13 19:46           ` Eli Zaretskii
2024-02-13 20:02             ` Spencer Baugh
2024-02-13 20:04               ` Eli Zaretskii
2024-02-13 20:20                 ` Spencer Baugh
2024-02-14 14:23                   ` Eli Zaretskii
2024-02-14 16:11                     ` Spencer Baugh
2024-02-24  9:20                       ` Eli Zaretskii
2024-02-13 13:02   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-13 21:30 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found] ` <875xys127y.fsf@>
2024-02-14 14:35   ` Eli Zaretskii
2024-02-14 15:10     ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]     ` <87plwzytcg.fsf@>
2024-02-14 15:31       ` Eli Zaretskii
2024-02-14 17:40         ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ierle886m95.fsf@janestreet.com \
    --to=sbaugh@janestreet.com \
    --cc=68799@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.