[SYSV_IPC] (main): Catch SIGHUP as well. Don't
authorRichard M. Stallman <rms@gnu.org>
Tue, 18 Oct 1994 11:23:18 +0000 (11:23 +0000)
committerRichard M. Stallman <rms@gnu.org>
Tue, 18 Oct 1994 11:23:18 +0000 (11:23 +0000)
call kill with pid 0.  Handle EINTR when receiving messages.

lib-src/emacsserver.c

index 1c8fc1d..1017639 100644 (file)
@@ -252,6 +252,11 @@ main ()
 #include <sys/ipc.h>
 #include <sys/msg.h>
 #include <setjmp.h>
+#include <errno.h>
+
+#ifndef errno
+extern int errno;
+#endif
 
 jmp_buf msgenv;
 
@@ -303,11 +308,13 @@ main ()
   if (setjmp (msgenv))
     {
       msgctl (s, IPC_RMID, 0);
-      kill (p, SIGKILL);
+      if (p > 0)
+       kill (p, SIGKILL);
       exit (0);
     }
   signal (SIGTERM, msgcatch);
   signal (SIGINT, msgcatch);
+  signal (SIGHUP, msgcatch);
   if (p > 0)
     {
       /* This is executed in the original process that did the fork above.  */
@@ -349,6 +356,10 @@ main ()
     {
       if ((fromlen = msgrcv (s, msgp, BUFSIZ - 1, 1, 0)) < 0)
         {
+#ifdef EINTR
+         if (errno == EINTR)
+           continue;
+#endif
          perror ("msgrcv");
          exit (1);
         }