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);
the only way to do it. */
char *popen_argv[3];
FILE *p;
+ pid_t pid;
popen_argv[0] = SENDMAIL;
popen_argv[1] = spambucket;
popen_argv[2] = NULL;
debug(D_COPY, "calling %s %s", SENDMAIL, spambucket);
- p = popenv(popen_argv, "w");
+ p = popenv(popen_argv, "w",&pid);
if (!p)
{
debug(D_COPY, "popenv failed(%s). Will not send a copy to spambucket", strerror(errno));
// Send message provided by SpamAssassin
fwrite(assassin->d().c_str(), assassin->d().size(), 1, p);
fclose(p); p = NULL;
+ waitpid(pid,0,0);
}
}
return SMFIS_REJECT;
char buf[1024];
char *popen_argv[4];
+ pid_t pid;
popen_argv[0] = SENDMAIL;
popen_argv[1] = "-bv";
debug(D_RCPT, "calling %s -bv %s", SENDMAIL, envrcpt[0]);
- p = popenv(popen_argv, "r");
+ p = popenv(popen_argv, "r", &pid);
if (!p)
{
debug(D_RCPT, "popenv failed(%s). Will not expand aliases", strerror(errno));
}
}
fclose(p); p = NULL;
+ waitpid(pid,0,0);
+
}
} else
{
for simplicity, and always reads stdout and stderr in "r" mode. Call
fclose to close the FILE.
*/
-FILE *popenv(char *const argv[], const char *type)
+FILE *popenv(char *const argv[], const char *type, pid_t *pid)
{
FILE *iop;
int pdes[2];
int save_errno;
+
if ((*type != 'r' && *type != 'w') || type[1])
{
errno = EINVAL;
}
if (pipe(pdes) < 0)
return (NULL);
- switch (fork()) {
+
+ *pid = fork();
+ switch (*pid) {
case -1: /* Error. */
save_errno = errno;