From 6a2845a13efa8e77d24df2347b0c2f381b344583 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 7 Dec 1996 01:04:27 +0000 Subject: Fix the SIGCLD snafu. svn path=/trunk/; revision=613 --- driver.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'driver.c') diff --git a/driver.c b/driver.c index a390bc29..40851052 100644 --- a/driver.c +++ b/driver.c @@ -296,6 +296,7 @@ struct query *ctl; /* query control record */ int n, oldlen, mboxfd; int inheaders,lines,sizeticker; FILE *sinkfp; + RETSIGTYPE (*sigchld)(); #ifdef HAVE_GETHOSTBYNAME char rbuf[HOSTLEN + USERNAMELEN + 4]; #endif /* HAVE_GETHOSTBYNAME */ @@ -531,6 +532,8 @@ struct query *ctl; /* query control record */ fprintf(stderr, "fetchmail: MDA open failed\n"); return(PS_IOERR); } + + sigchld = signal(SIGCLD, SIG_DFL); } else { @@ -623,6 +626,11 @@ struct query *ctl; /* query control record */ free(headers); headers = NULL; perror("fetchmail: writing RFC822 headers"); + if (ctl->mda[0]) + { + closemailpipe(mboxfd); + signal(SIGCLD, sigchld); + } return(PS_IOERR); } else if (outlevel == O_VERBOSE) @@ -706,6 +714,11 @@ struct query *ctl; /* query control record */ if (n < 0) { perror("fetchmail: writing message text"); + if (ctl->mda[0]) + { + closemailpipe(mboxfd); + signal(SIGCLD, sigchld); + } return(PS_IOERR); } else if (outlevel == O_VERBOSE) @@ -717,8 +730,12 @@ struct query *ctl; /* query control record */ if (ctl->mda[0]) { + int rc; + /* close the delivery pipe, we'll reopen before next message */ - if (closemailpipe(mboxfd)) + rc = closemailpipe(mboxfd); + signal(SIGCLD, sigchld); + if (rc) return(PS_IOERR); } else if (sinkfp) -- cgit v1.2.3