FIFO existence is used to test for a running kernel.
[egate.git] / kernel / main.c
index 10dc733..fd6ef7e 100644 (file)
@@ -2,7 +2,10 @@
  * Europagate, 1995
  *
  * $Log: main.c,v $
- * Revision 1.12  1995/03/27 12:51:05  adam
+ * Revision 1.13  1995/03/28 08:01:25  adam
+ * FIFO existence is used to test for a running kernel.
+ *
+ * Revision 1.12  1995/03/27  12:51:05  adam
  * New log level in use: GW_LOG_ERRNO.
  *
  * Revision 1.11  1995/03/27  08:24:02  adam
@@ -63,32 +66,6 @@ FILE *reply_fd = stdout;
 
 struct gw_kernel_info info;
 
-static void mk_active (int userid)
-{
-    char active_name[1024];
-    char pid_buf[30];
-    int fd;
-
-    sprintf (active_name, "kernel.pid.%d", userid);
-    fd = open (active_name, O_WRONLY|O_CREAT, 0666);
-    if (fd == -1)
-    {
-        gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, "Cannot create %s", active_name);
-       exit (1);
-    }
-    sprintf (pid_buf, "%ld", (long) getpid()); 
-    write (fd, pid_buf, strlen(pid_buf));
-    close (fd);
-}
-
-static void rm_active (int userid)
-{
-    char active_name[1024];
-
-    sprintf (active_name, "kernel.pid.%d", userid);
-    unlink (active_name);
-}
-
 static void kernel_events (int userid)
 {
     char fifo_client_name[1024];
@@ -131,7 +108,10 @@ static void kernel_events (int userid)
             char command[128], *cp;
 
            if (!(lgets (command, 127, gip_fd)))
+           {
+               gw_log (GW_LOG_WARN, KERNEL_LOG, "Unexpected close");
                break;
+           }
            if ((cp = strchr (command, '\n')))
                *cp = '\0';
            gw_log (GW_LOG_STAT, KERNEL_LOG, "IPC: %s", command);
@@ -153,6 +133,8 @@ static void kernel_events (int userid)
     }
     gips_close (gip);
     gips_destroy (gip);
+    unlink (fifo_client_name);
+    unlink (fifo_server_name);
 }
 
 int main (int argc, char **argv)
@@ -308,11 +290,7 @@ int main (int argc, char **argv)
     }
     read_kernel_res ();
     if (userid != -1)
-    {
-        mk_active (userid);
         kernel_events (userid);
-       rm_active (userid);
-    }
     else
         urp (0);
     return 0;