From 72925acd2e14bc2d0f67df235d405c24b9c11a51 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 6 Oct 1996 04:59:59 +0000 Subject: Crap out on nonzero MDA return status. svn path=/trunk/; revision=235 --- fetchmail.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'fetchmail.c') diff --git a/fetchmail.c b/fetchmail.c index 1fff5cca..19b08b01 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -566,20 +566,28 @@ struct hostrec *queryctl; int closemailpipe (fd) int fd; { - int err; + int err, status; int childpid; if (outlevel == O_VERBOSE) fprintf(stderr, "about to close pipe %d\n", fd); - err = close(fd); -#if defined(STDC_HEADERS) - childpid = wait(NULL); -#else - childpid = wait((int *) 0); + if ((err = close(fd)) != 0) + perror("fetchmail: closemailpipe: close failed"); + + childpid = wait(&status); + +#if defined(WIFEXITED) && defined(WEXITSTATUS) + /* + * Try to pass up an error if the MDA returned nonzero status, + * on the assumption that this means it was reporting failure. + */ + if (WIFEXITED(status) == 0 || WEXITSTATUS(status) != 0) + { + perror("fetchmail: MDA exited abnormally or returned nonzero status"); + err = -1; + } #endif - if (err) - perror("fetchmail: closemailpipe: close"); if (outlevel == O_VERBOSE) fprintf(stderr, "closed pipe %d\n", fd); -- cgit v1.2.3