up to the Emacs which then executes them. */
#define NO_SHORTNAMES
-#include "../src/config.h"
+#include <../src/config.h>
#undef read
#undef write
#undef open
#if ! defined (HAVE_SYSVIPC)
/* BSD code is very different from SYSV IPC code */
-#include <sys/file.h>
#include <sys/types.h>
+#include <sys/file.h>
#include <sys/socket.h>
#include <sys/signal.h>
#include <sys/un.h>
unlink (server.sun_path);
#endif
- if (bind (s, &server, strlen (server.sun_path) + 2) < 0)
+ if (bind (s, (struct sockaddr *) &server, strlen (server.sun_path) + 2) < 0)
{
perror ("bind");
exit (1);
{
fromlen = sizeof (fromunix);
fromunix.sun_family = AF_UNIX;
- infd = accept (s, &fromunix, &fromlen); /* open socket fd */
+ infd = accept (s, (struct sockaddr *) &fromunix, &fromlen); /* open socket fd */
if (infd < 0)
{
if (errno == EMFILE || errno == ENFILE)
}
signal (SIGTERM, msgcatch);
signal (SIGINT, msgcatch);
- /* If parent goes away, remove message box and exit */
- if (p == 0)
+ if (p > 0)
{
+ /* This is executed in the original process that did the fork above. */
+ /* Get pid of Emacs itself. */
p = getppid ();
setpgrp (); /* Gnu kills process group on exit */
while (1)
{
+ /* Is Emacs still alive? */
if (kill (p, 0) < 0)
{
msgctl (s, IPC_RMID, 0);
}
}
+ /* This is executed in the child made by forking above. */
while (1)
{
if ((fromlen = msgrcv (s, msgp, BUFSIZ - 1, 1, 0)) < 0)