]> git.donarmstrong.com Git - deb_pkgs/spamass-milter.git/blobdiff - spamass-milter.cpp
Fix zombies which were happening with -x. (closes: #575019)
[deb_pkgs/spamass-milter.git] / spamass-milter.cpp
index 65657c193021b13020da2e3c69a5cda7935a1f63..b88987152d46ef738dc62fd9998bf0cc7f15b76e 100644 (file)
@@ -183,6 +183,7 @@ main(int argc, char* argv[])
    bool dofork = false;
    char *pidfilename = NULL;
    FILE *pidfile = NULL;
+   struct sigaction children_sigaction;
 
 #ifdef HAVE_VERBOSE_TERMINATE_HANDLER
        std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
@@ -345,6 +346,13 @@ main(int argc, char* argv[])
       if (stat(sock,&junk) == 0) unlink(sock);
    }
 
+   /* We don't care about any of our children, so ignore all of them */
+   /* Set up sigaction to avoid having to reap children */
+   memset(&children_sigaction, 0, sizeof children_sigaction);
+   children_sigaction.sa_flags = SA_NOCLDWAIT;
+   sigaction(SIG_CHLD,&children_sigaction,0);
+
+
    (void) smfi_setconn(sock);
        if (smfi_register(smfilter) == MI_FAILURE) {
                fprintf(stderr, "smfi_register failed\n");
@@ -2131,6 +2139,8 @@ FILE *popenv(char *const argv[], const char *type)
        FILE *iop;
        int pdes[2];
        int save_errno;
+       pid_t pid;
+
        if ((*type != 'r' && *type != 'w') || type[1])
        {
                errno = EINVAL;
@@ -2138,7 +2148,9 @@ FILE *popenv(char *const argv[], const char *type)
        }
        if (pipe(pdes) < 0)
                return (NULL);
-       switch (fork()) {
+       
+       pid = fork();
+       switch (pid) {
        
        case -1:                        /* Error. */
                save_errno = errno;