/* 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,
main ()
{
+ char system_name[32];
int s, infd, fromlen;
struct sockaddr_un server, fromunix;
char *homedir;
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");
jmp_buf msgenv;
+SIGTYPE
msgcatch ()
{
longjmp (msgenv, 1);
if ((fromlen = msgrcv (s, msgp, BUFSIZ - 1, 1, 0)) < 0)
{
perror ("msgrcv");
+ exit (1);
}
else
{