(install-doc): New target.
[bpt/emacs.git] / lib-src / emacsserver.c
index fc5f33d..cf7a6dd 100644 (file)
@@ -25,7 +25,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
    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
@@ -48,8 +48,8 @@ main ()
 #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>
@@ -108,7 +108,7 @@ main ()
   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);
@@ -135,7 +135,7 @@ main ()
        {
          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)
@@ -282,13 +282,15 @@ main ()
     }
   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);
@@ -298,6 +300,7 @@ main ()
        }
     }
 
+  /* This is executed in the child made by forking above.  */
   while (1)
     {
       if ((fromlen = msgrcv (s, msgp, BUFSIZ - 1, 1, 0)) < 0)