/* Client process that communicates with GNU Emacs acting as server.
- Copyright (C) 1986, 1987, 1994, 1999, 2000, 2001, 2003
+ Copyright (C) 1986, 1987, 1994, 1999, 2000, 2001, 2003, 2004
Free Software Foundation, Inc.
This file is part of GNU Emacs.
#endif
#endif
+/* A signal handler that passes the signal to the Emacs process.
+ Useful for SIGWINCH. */
+
SIGTYPE
-window_change_signal (int signalnum)
+pass_signal_to_emacs (int signalnum)
{
int old_errno = errno;
if (emacs_pid)
- kill (emacs_pid, SIGWINCH);
+ kill (emacs_pid, signalnum);
- signal (SIGWINCH, window_change_signal);
+ signal (signalnum, pass_signal_to_emacs);
errno = old_errno;
}
+/* Set up signal handlers before opening a frame on the current tty. */
+
void
init_signals (void)
{
/* Set up signal handlers. */
- signal (SIGWINCH, window_change_signal);
+ signal (SIGWINCH, pass_signal_to_emacs);
+
+ /* Don't pass SIGINT and SIGQUIT to Emacs, because it has no way of
+ deciding which terminal the signal came from. C-g is now a
+ normal input event on secondary terminals. */
+#if 0
+ signal (SIGINT, pass_signal_to_emacs);
+ signal (SIGQUIT, pass_signal_to_emacs);
+#endif
}
\f
{
int sock_status = 0;
- int oerrno = 0;
+ int default_sock = !socket_name;
+ int saved_errno = 0;
- if (! socket_name)
+ if (default_sock)
{
socket_name = alloca (system_name_length + 100);
sprintf (socket_name, "/tmp/emacs%d-%s/server",
/* See if the socket exists, and if it's owned by us. */
sock_status = socket_status (server.sun_path);
- oerrno = errno;
- if (sock_status)
+ saved_errno = errno;
+ if (sock_status && default_sock)
{
/* Failing that, see if LOGNAME or USER exist and differ from
our euid. If so, look for a socket based on the UID
if (pw && (pw->pw_uid != geteuid ()))
{
/* We're running under su, apparently. */
- sprintf (server.sun_path, "/tmp/esrv%d-%s",
+ sprintf (socket_name, "/tmp/emacs%d-%s/server",
(int) pw->pw_uid, system_name);
+
+ if (strlen (socket_name) < sizeof (server.sun_path))
+ strcpy (server.sun_path, socket_name);
+ else
+ {
+ fprintf (stderr, "%s: socket-name %s too long",
+ argv[0], socket_name);
+ exit (1);
+ }
+
sock_status = socket_status (server.sun_path);
- oerrno = errno;
+ saved_errno = errno;
}
}
}
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 (oerrno));
+ argv[0], server.sun_path, strerror (saved_errno));
fail ();
break;
}