]> andersk Git - moira.git/commitdiff
listen for SIGCHLDs to avoid zombies
authordanw <danw>
Mon, 9 Nov 1998 22:48:18 +0000 (22:48 +0000)
committerdanw <danw>
Mon, 9 Nov 1998 22:48:18 +0000 (22:48 +0000)
update/update_server.c

index d93a5dbdb20681d668afb24e4a8cb9c00db24d9f..a0832e6b2c13ee0b125f8ecb8cc1591f199e833c 100644 (file)
 
 #include <sys/stat.h>
 #include <sys/utsname.h>
+#include <sys/wait.h>
 
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
 #include <errno.h>
 #include <pwd.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -33,6 +35,8 @@ int have_authorization = 0;
 des_cblock session;
 int uid = 0;
 
+void child_handler(int signal);
+
 struct _dt {
   char *str;
   void (*proc)(int, char *);
@@ -52,6 +56,7 @@ int main(int argc, char **argv)
   struct _dt *d;
   struct utsname name;
   int s, conn;
+  struct sigaction sa;
 
   whoami = strrchr(argv[0], '/');
   if (whoami)
@@ -79,6 +84,11 @@ int main(int argc, char **argv)
   umask(0022);
   mr_init();
 
+  sigemptyset(&sa.sa_mask);
+  sa.sa_flags = SA_RESTART;
+  sa.sa_handler = child_handler;
+  sigaction(SIGCHLD, &sa, NULL);
+
   /* If the config file contains a line "user username", the
    * daemon will run with that user's UID.
    */
@@ -210,3 +220,11 @@ void fail(int conn, int err, char *msg)
   close(conn);
   exit(1);
 }
+
+void child_handler(int signal)
+{
+  int status;
+
+  while (waitpid(-1, &status, WNOHANG) > 0)
+    ;
+}
This page took 0.0393559999999999 seconds and 5 git commands to generate.