changeset 100453:40eb1f585dc7

* server.el (server-start): If unable to start the server, display a warning instead of raising an error. * startup.el (server-process): Add defvar. (command-line): If the daemon is unable to start the server, display a message and exit Emacs.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 16 Dec 2008 21:23:03 +0000
parents 9d19a4d3205f
children b8d5bfa98123
files lisp/ChangeLog lisp/server.el lisp/startup.el
diffstat 3 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Dec 16 13:32:31 2008 +0000
+++ b/lisp/ChangeLog	Tue Dec 16 21:23:03 2008 +0000
@@ -1,3 +1,12 @@
+2008-12-16  Juanma Barranquero  <lekktu@gmail.com>
+
+	* server.el (server-start): If unable to start the server,
+	display a warning instead of raising an error.
+
+	* startup.el (server-process): Add defvar.
+	(command-line): If the daemon is unable to start the server,
+	display a message and exit Emacs.
+
 2008-12-15  Sam Steingold  <sds@gnu.org>
 
 	* progmodes/cc-cmds.el (c-defun-name): Handle DEFFOO(name,...),
--- a/lisp/server.el	Tue Dec 16 13:32:31 2008 +0000
+++ b/lisp/server.el	Tue Dec 16 21:23:03 2008 +0000
@@ -479,14 +479,17 @@
 	  ;; Remove any leftover socket or authentication file
 	  (ignore-errors (delete-file server-file))
 	(setq server-mode nil) ;; already set by the minor mode code
-	(error "Server %S is already running" server-name))
+	(display-warning 'server
+			 (format "Emacs server named %S already running" server-name)
+			 :warning)
+	(setq leave-dead t))
       ;; If this Emacs already had a server, clear out associated status.
       (while server-clients
 	(server-delete-client (car server-clients)))
       ;; Now any previous server is properly stopped.
       (if leave-dead
 	  (progn
-	    (server-log (message "Server stopped"))
+	    (unless (eq t leave-dead) (server-log (message "Server stopped")))
 	    (setq server-process nil))
 	;; Make sure there is a safe directory in which to place the socket.
 	(server-ensure-safe-dir server-dir)
--- a/lisp/startup.el	Tue Dec 16 13:32:31 2008 +0000
+++ b/lisp/startup.el	Tue Dec 16 21:23:03 2008 +0000
@@ -694,6 +694,7 @@
 (declare-function tool-bar-setup "tool-bar")
 
 (defvar server-name)
+(defvar server-process)
 
 (defun command-line ()
   (setq before-init-time (current-time)
@@ -1220,7 +1221,10 @@
     (when dn
       (when (stringp dn) (setq server-name dn))
       (server-start)
-      (daemon-initialized)))
+      (if server-process
+	  (daemon-initialized)
+	(message "Unable to start daemon: Emacs server named %S already running" server-name)
+	(kill-emacs 1))))
 
   ;; Run emacs-session-restore (session management) if started by
   ;; the session manager and we have a session manager connection.