From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#68799: 30.0.50; emacs --fg-daemon fails silently if server-start fails Date: Mon, 29 Jan 2024 13:13:42 -0500 Message-ID: References: <86y1c82hfb.fsf@gnu.org> <86wmrs2h41.fsf@gnu.org> <86v87c2fw4.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31910"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 68799@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 29 19:14:10 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rUW93-00086Z-Db for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 29 Jan 2024 19:14:09 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUW8p-0006YO-TX; Mon, 29 Jan 2024 13:13:56 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUW8o-0006Y3-5O for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2024 13:13:54 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rUW8n-0006Oh-Qh for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2024 13:13:53 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rUW8w-0006YA-6w for bug-gnu-emacs@gnu.org; Mon, 29 Jan 2024 13:14:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 29 Jan 2024 18:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68799 X-GNU-PR-Package: emacs Original-Received: via spool by 68799-submit@debbugs.gnu.org id=B68799.170655203925163 (code B ref 68799); Mon, 29 Jan 2024 18:14:02 +0000 Original-Received: (at 68799) by debbugs.gnu.org; 29 Jan 2024 18:13:59 +0000 Original-Received: from localhost ([127.0.0.1]:33426 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUW8s-0006Xm-Mo for submit@debbugs.gnu.org; Mon, 29 Jan 2024 13:13:59 -0500 Original-Received: from mxout6.mail.janestreet.com ([64.215.233.21]:49449) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUW8q-0006XZ-KS for 68799@debbugs.gnu.org; Mon, 29 Jan 2024 13:13:57 -0500 In-Reply-To: <86v87c2fw4.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 29 Jan 2024 19:44:43 +0200") DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1706552022; bh=2vLqDTdkLeK69fGIe7OmvGr9s84FMSxttZP5oxEEcn4=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=lLGnovzVluUjI2tc1wsEojhFfdpGfqGaUdBU4+O9uimm/1AL2J34ajGiCpXyUoqUY pX5EY7F3yLb+Xhj78UJSqg8DJaEFu7deg/5DCo5GNGIPlAWKaQ5KAuuomgCiWFZjtU L7z2suOV50XgL1bPMSIgNmKZ6Yb+5ZXJjmQ/rel4LK4HTCjTX1L1VkkAlhN3+/EclY Tvxp59iFCfvkVtBHR2es7BdWg+1ny3ydwYDAhowIHE1Alv+11PVTO2lR/6Jc2wc2Rl GafU5zS4gSMVmz8QsYTXOre7rOpEC55ylpswqURfQBGyOLOkJI1P2T9Pgt4EsKxbvf uLz9lLKzVP0OQ== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:279139 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Spencer Baugh >> Cc: 68799@debbugs.gnu.org >> Date: Mon, 29 Jan 2024 12:32:00 -0500 >> >> Eli Zaretskii 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Message-when-server-start-errors-in-emacs-daemon.patch >From 2a6f039663a678d0fcae47318011fbb5d8bb5f1c Mon Sep 17 00:00:00 2001 From: Spencer Baugh 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 --=-=-=--