From fd95644b937fb3e6e1285b21c2fc1ab901199e87 Mon Sep 17 00:00:00 2001 From: Dan Nicolaescu Date: Thu, 18 Dec 2008 08:48:26 +0000 Subject: [PATCH] * emacs.c (main): Print and error and exit when no data is read from the pipe. * startup.el (command-line): Do not mention the server name in case the user has not mentioned it, print a more explicit message. * emacsclient.c (start_daemon_and_retry_set_socket): Improve error checking. --- lib-src/ChangeLog | 5 +++++ lib-src/emacsclient.c | 22 +++++++++++++++------- lisp/ChangeLog | 3 +++ lisp/startup.el | 6 +++++- src/ChangeLog | 5 +++++ src/emacs.c | 5 +++++ 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 16d70d4297..b72487d22d 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,8 @@ +2008-12-18 Dan Nicolaescu + + * emacsclient.c (start_daemon_and_retry_set_socket): Improve error + checking. + 2008-12-14 Dan Nicolaescu * emacsclient.c: Include syswait.h instead of sys/types.h. diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 2f18fee504..22b5273f84 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -1433,23 +1433,31 @@ start_daemon_and_retry_set_socket (void) #ifndef WINDOWSNT pid_t dpid; int status; - pid_t p; dpid = fork (); if (dpid > 0) { - p = waitpid (dpid, &status, WUNTRACED | WCONTINUED); + pid_t w; + w = waitpid (dpid, &status, WUNTRACED | WCONTINUED); - /* Try connecting again, the daemon should have started by - now. */ - message (TRUE, "daemon should have started, trying to connect again\n", dpid); + if ((w == -1) || !WIFEXITED (status) || WEXITSTATUS(status)) + { + message (TRUE, "Error: Could not start the Emacs daemon\n"); + exit (EXIT_FAILURE); + } + + /* Try connecting, the daemon should have started by now. */ + message (TRUE, "Emacs daemon should have started, trying to connect again\n"); if ((emacs_socket = set_socket (1)) == INVALID_SOCKET) - message (TRUE, "Cannot connect even after starting the daemon\n"); + { + message (TRUE, "Error: Cannot connect even after starting the Emacs daemon\n"); + exit (EXIT_FAILURE); + } } else if (dpid < 0) { - fprintf (stderr, "Cannot fork!\n"); + fprintf (stderr, "Error: Cannot fork!\n"); exit (1); } else diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9adef563e0..0c06b012fd 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2008-12-18 Dan Nicolaescu + * startup.el (command-line): Do not mention the server name in + case the user has not mentioned it, print a more explicit message. + * vc-dir.el (vc-dir-at-event): Rename from vc-at-event. Change all callers. diff --git a/lisp/startup.el b/lisp/startup.el index 2fa1a6c15c..6dc958cae3 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -1223,7 +1223,11 @@ the `--debug-init' option to view a complete error backtrace." (server-start) (if server-process (daemon-initialized) - (message "Unable to start daemon: Emacs server named %S already running" server-name) + (if (stringp dn) + (message + "Unable to start daemon: Emacs server named %S already running" + server-name) + (message "Unable to start the daemon.\nAnother instance of Emacs is running the server, either as daemon or interactively.\nYou can use emacsclient to connect to that Emacs process.")) (kill-emacs 1)))) ;; Run emacs-session-restore (session management) if started by diff --git a/src/ChangeLog b/src/ChangeLog index 8177bea8a4..ccda62889f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-12-18 Dan Nicolaescu + + * emacs.c (main): Print and error and exit when no data is read + from the pipe. + 2008-12-17 Jason Rumney * w32font.c (w32font_has_char): Always return -1. diff --git a/src/emacs.c b/src/emacs.c index bd733da303..4ebf136063 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1129,6 +1129,11 @@ main (int argc, char **argv) fprintf (stderr, "Error reading status from child\n"); exit (1); } + else if (retval == 0) + { + fprintf (stderr, "Error: server did not start correctly\n"); + exit (1); + } close (daemon_pipe[0]); exit (0); -- 2.20.1