changeset 53543:fec82b542db2

(main): Save errno from socket_status.
author Andreas Schwab <schwab@suse.de>
date Thu, 08 Jan 2004 12:20:32 +0000
parents 8bfc55c02f6f
children 41011f848610
files lib-src/emacsclient.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/emacsclient.c	Thu Jan 08 08:40:12 2004 +0000
+++ b/lib-src/emacsclient.c	Thu Jan 08 12:20:32 2004 +0000
@@ -358,6 +358,7 @@
 
   {
     int sock_status = 0;
+    int saved_errno;
 
     if (! socket_name)
       {
@@ -374,6 +375,7 @@
 
     /* See if the socket exists, and if it's owned by us. */
     sock_status = socket_status (server.sun_path);
+    saved_errno = errno;
     if (sock_status)
       {
 	/* Failing that, see if LOGNAME or USER exist and differ from
@@ -394,6 +396,7 @@
 		sprintf (server.sun_path, "/tmp/emacs%d-%s/server",
 			 (int) pw->pw_uid, system_name);
 		sock_status = socket_status (server.sun_path);
+		saved_errno = errno;
 	      }
 	  }
       }
@@ -412,14 +415,14 @@
 
        case 2:
 	 /* `stat' failed */
-	 if (errno == ENOENT)
+	 if (saved_errno == ENOENT)
 	   fprintf (stderr,
 		    "%s: can't find socket; have you started the server?\n\
 To start the server in Emacs, type \"M-x server-start\".\n",
 		    argv[0]);
 	 else
 	   fprintf (stderr, "%s: can't stat %s: %s\n",
-		    argv[0], server.sun_path, strerror (errno));
+		    argv[0], server.sun_path, strerror (saved_errno));
 	 fail (argc, argv);
 	 break;
        }