changeset 110706:ab3815920cc5

* emacsclient.c (main): Return EXIT_FAILURE if Emacs sends us an error string (Bug#6963).
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 02 Oct 2010 20:00:01 -0400
parents 039bf20a0a30
children 17914d74ccf4
files lib-src/ChangeLog lib-src/emacsclient.c
diffstat 2 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/ChangeLog	Sat Oct 02 19:10:41 2010 -0400
+++ b/lib-src/ChangeLog	Sat Oct 02 20:00:01 2010 -0400
@@ -1,3 +1,8 @@
+2010-10-02  Wolfgang Schnerring  <wosc@wosc.de>  (tiny change)
+
+	* emacsclient.c (main): Return EXIT_FAILURE if Emacs sends us an
+	error string (Bug#6963).
+
 2010-10-02  Juanma Barranquero  <lekktu@gmail.com>
 
 	* makefile.w32-in (tags): Remove target.
--- a/lib-src/emacsclient.c	Sat Oct 02 19:10:41 2010 -0400
+++ b/lib-src/emacsclient.c	Sat Oct 02 20:00:01 2010 -0400
@@ -1499,6 +1499,7 @@
   char *cwd, *str;
   char string[BUFSIZ+1];
   int null_socket_name, null_server_file, start_daemon_if_needed;
+  int exit_status = EXIT_SUCCESS;
 
   main_argv = argv;
   progname = argv[0];
@@ -1698,7 +1699,8 @@
   fsync (1);
 
   /* Now, wait for an answer and print any messages.  */
-  while ((rl = recv (emacs_socket, string, BUFSIZ, 0)) > 0)
+  while (exit_status == EXIT_SUCCESS
+	 && (rl = recv (emacs_socket, string, BUFSIZ, 0)) > 0)
     {
       char *p;
       string[rl] = '\0';
@@ -1737,6 +1739,7 @@
             printf ("\n");
           fprintf (stderr, "*ERROR*: %s", str);
           needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
+	  exit_status = EXIT_FAILURE;
         }
 #ifdef SIGSTOP
       else if (strprefix ("-suspend ", string))
@@ -1754,7 +1757,8 @@
           if (needlf)
             printf ("\n");
           printf ("*ERROR*: Unknown message: %s", string);
-          needlf = string[0] == '\0' ? needlf : string[strlen (string) - 1] != '\n';
+          needlf = string[0]
+	    == '\0' ? needlf : string[strlen (string) - 1] != '\n';
         }
     }
 
@@ -1763,8 +1767,11 @@
   fflush (stdout);
   fsync (1);
 
+  if (rl < 0)
+    exit_status = EXIT_FAILURE;
+
   CLOSE_SOCKET (emacs_socket);
-  return EXIT_SUCCESS;
+  return exit_status;
 }
 
 #endif /* HAVE_SOCKETS && HAVE_INET_SOCKETS */