]> git.eshelyaron.com Git - emacs.git/commitdiff
(main): Eliminate arbitrary limit on
authorRichard M. Stallman <rms@gnu.org>
Sat, 16 Jan 1999 21:44:56 +0000 (21:44 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sat, 16 Jan 1999 21:44:56 +0000 (21:44 +0000)
lib-src/emacsserver.c

index 00bf923bf524aff3d39276b0c894e87cb736ee5c..b25b58f38aa8d69640fa8c8aa87bc9a0b587eb0b 100644 (file)
@@ -213,7 +213,8 @@ main (argc, argv)
      int argc;
      char **argv;
 {
-  char system_name[32];
+  char *system_name;
+  int system_name_length;
   int s, infd;
 #ifdef SOCKLEN_TYPE
   SOCKLEN_TYPE fromlen;
@@ -250,9 +251,22 @@ main (argc, argv)
     }
   server.sun_family = AF_UNIX;
 #ifndef SERVER_HOME_DIR
-  gethostname (system_name, sizeof (system_name));
-  /* system_name must be null-terminated string */
-  system_name[sizeof (system_name) - 1] = '\0';
+  system_name_length = 32;
+
+  while (1)
+    {
+      system_name = (char *) xmalloc (system_name_length + 1);
+
+      /* system_name must be null-terminated string.  */
+      system_name[system_name_length] = '\0';
+
+      if (gethostname (system_name, system_name_length) == 0)
+       break;
+
+      free (system_name);
+      system_name_length *= 2;
+    }
+
   sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name);
 
   if (unlink (server.sun_path) == -1 && errno != ENOENT)