]> code.delx.au - gnu-emacs/blobdiff - lib-src/emacsserver.c
Install patches from David J. Mackenzie to make the srcdir option
[gnu-emacs] / lib-src / emacsserver.c
index 19e4e430ab33f8749a950291862e3ce265ddf5ea..19de7e66eb86c2eefabc5514d1b480cda4da0b3e 100644 (file)
@@ -1,11 +1,11 @@
 /* Communication subprocess for GNU Emacs acting as server.
-   Copyright (C) 1986, 1987 Free Software Foundation, Inc.
+   Copyright (C) 1986, 1987, 1992 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -59,6 +59,7 @@ extern int errno;
 
 main ()
 {
+  char system_name[32];
   int s, infd, fromlen;
   struct sockaddr_un server, fromunix;
   char *homedir;
@@ -85,21 +86,27 @@ main ()
       exit (1);
     }
   server.sun_family = AF_UNIX;
-  homedir = getenv ("HOME");
-  if (homedir == NULL)
+#ifndef SERVER_HOME_DIR
+  gethostname (system_name, sizeof (system_name));
+  sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name);
+
+  if (unlink (server.sun_path) == -1 && errno != ENOENT)
+    {
+      perror ("unlink");
+      exit (1);
+    }
+#else  
+  if ((homedir = getenv ("HOME")) == NULL)
     {
       fprintf (stderr,"No home directory\n");
       exit (1);
     }
-  sprintf (server.sun_path, "/tmp/esrv%d", geteuid ());
-
-#if 0
   strcpy (server.sun_path, homedir);
   strcat (server.sun_path, "/.emacs_server");
-#endif
-
   /* Delete anyone else's old server.  */
   unlink (server.sun_path);
+#endif
+
   if (bind (s, &server, strlen (server.sun_path) + 2) < 0)
     {
       perror ("bind");
@@ -221,6 +228,7 @@ main ()
 
 jmp_buf msgenv;
 
+SIGTYPE
 msgcatch ()
 {
   longjmp (msgenv, 1);
@@ -294,6 +302,7 @@ main ()
       if ((fromlen = msgrcv (s, msgp, BUFSIZ - 1, 1, 0)) < 0)
         {
          perror ("msgrcv");
+         exit (1);
         }
       else
         {