From: don Date: Mon, 22 Mar 2010 21:39:30 +0000 (+0000) Subject: Fix zombies which were happening with -x. (closes: #575019) X-Git-Tag: debian/0.4.0-1~40 X-Git-Url: https://git.donarmstrong.com/?p=deb_pkgs%2Fspamass-milter.git;a=commitdiff_plain;h=01af70d23bc3ae5715c5783b96c5581afbc68960 Fix zombies which were happening with -x. (closes: #575019) --- diff --git a/debian/changelog b/debian/changelog index a710586..05a370d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +spamass-milter (0.3.1-10) unstable; urgency=low + + * Fix zombies which were happening with -x. (closes: #575019) + + -- Don Armstrong Mon, 22 Mar 2010 14:39:12 -0700 + spamass-milter (0.3.1-9) unstable; urgency=high * Call restorecon on the socket and pidfile directories to make SELinux diff --git a/spamass-milter.cpp b/spamass-milter.cpp index 65657c1..b889871 100644 --- a/spamass-milter.cpp +++ b/spamass-milter.cpp @@ -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;