diff options
author | Richard M. Stallman <rms@gnu.org> | 1999-01-16 21:44:56 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1999-01-16 21:44:56 +0000 |
commit | 40beb971f4015cea4252d2f1e7dfb130a8f1ae75 (patch) | |
tree | 573fce9c8ad6fba8e2b6cea75e68ddd90fbad25f /lib-src | |
parent | b6a98c5219d407694d3e0aef199eb0c0ee8712d8 (diff) | |
download | emacs-40beb971f4015cea4252d2f1e7dfb130a8f1ae75.tar.gz |
(main): Eliminate arbitrary limit on
Diffstat (limited to 'lib-src')
-rw-r--r-- | lib-src/emacsserver.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib-src/emacsserver.c b/lib-src/emacsserver.c index 00bf923bf52..b25b58f38aa 100644 --- a/lib-src/emacsserver.c +++ b/lib-src/emacsserver.c @@ -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) |