# HG changeset patch # User Dan Nicolaescu # Date 1229590106 0 # Node ID fd10c7ef5447ed907156a9f9e45f921c5d715a95 # Parent 023acf8058b5854a793b475e8819629282ee0702 * 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. diff -r 023acf8058b5 -r fd10c7ef5447 lib-src/ChangeLog --- a/lib-src/ChangeLog Thu Dec 18 08:30:41 2008 +0000 +++ b/lib-src/ChangeLog Thu Dec 18 08:48:26 2008 +0000 @@ -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 -r 023acf8058b5 -r fd10c7ef5447 lib-src/emacsclient.c --- a/lib-src/emacsclient.c Thu Dec 18 08:30:41 2008 +0000 +++ b/lib-src/emacsclient.c Thu Dec 18 08:48:26 2008 +0000 @@ -1433,23 +1433,31 @@ #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 -r 023acf8058b5 -r fd10c7ef5447 lisp/ChangeLog --- a/lisp/ChangeLog Thu Dec 18 08:30:41 2008 +0000 +++ b/lisp/ChangeLog Thu Dec 18 08:48:26 2008 +0000 @@ -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 -r 023acf8058b5 -r fd10c7ef5447 lisp/startup.el --- a/lisp/startup.el Thu Dec 18 08:30:41 2008 +0000 +++ b/lisp/startup.el Thu Dec 18 08:48:26 2008 +0000 @@ -1223,7 +1223,11 @@ (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 -r 023acf8058b5 -r fd10c7ef5447 src/ChangeLog --- a/src/ChangeLog Thu Dec 18 08:30:41 2008 +0000 +++ b/src/ChangeLog Thu Dec 18 08:48:26 2008 +0000 @@ -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 -r 023acf8058b5 -r fd10c7ef5447 src/emacs.c --- a/src/emacs.c Thu Dec 18 08:30:41 2008 +0000 +++ b/src/emacs.c Thu Dec 18 08:48:26 2008 +0000 @@ -1129,6 +1129,11 @@ 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);