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 --- NEWS | 16 ++++++++++++---- driver.c | 19 ++++++++++++++++++- fetchmail.c | 3 +++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index fc96f342..c551482f 100644 --- a/NEWS +++ b/NEWS @@ -7,16 +7,24 @@ features -- * If SMTP returns 571 (unsolicited mail refused) to a MAIL FROM, the address is excluded by the local sendmail's spam filter. Drop the mail. - (This the only circumstance in which mail is thrown away.) + (This is the only circumstance in which mail is thrown away.) bugs -- -* Fixed a startup-time core dump introduced by 2.1's aka-list feature -* Fixed a bug in non-implicit (poll specified host) mode also due to aka. -* Various minor portability fixes for Suns. +* Fixed a startup-time core dump introduced by 2.1's aka-list feature. + +* Fixed a bug in non-implicit mode (poll specified host), also due to aka. + +* Various minor portability fixes for Suns. Adding #include + in fetchmail.c was the most significant one. + * Avoid using -lresolv when possible, some Linux versions are badly broken. + * Fix error in MX record handling that was causing multidrop problems. +* Disable daemon SIGCLD handler while an MDA is running, to avoid snafus. + Thanks to Dave Bodenstab for spotting this obscure bug. + 153 people on the contact list. ------------------------------------------------------------------------------ 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) diff --git a/fetchmail.c b/fetchmail.c index 83ce10ef..a560efbe 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -128,6 +128,9 @@ int main (int argc, char **argv) if ((parsestatus = parsecmdline(argc,argv,&cmd_opts)) < 0) exit(PS_SYNTAX); + /* this hint to stdio should halp messages come out in the right order */ + setvbuf(stdout, NULL, _IOLBF, POPBUFSIZE); + if (versioninfo) printf("This is fetchmail release %s pl %s\n", RELEASE_ID, PATCHLEVEL); -- cgit v1.2.3