aboutsummaryrefslogtreecommitdiffstats
path: root/fetchmail.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-10-06 04:59:59 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-10-06 04:59:59 +0000
commit72925acd2e14bc2d0f67df235d405c24b9c11a51 (patch)
tree3d20d8230a7cce143feee781acfcb608e2fa301a /fetchmail.c
parent46c5e84c827ac46b14dc324a32e4eb76a38bd91c (diff)
downloadfetchmail-72925acd2e14bc2d0f67df235d405c24b9c11a51.tar.gz
fetchmail-72925acd2e14bc2d0f67df235d405c24b9c11a51.tar.bz2
fetchmail-72925acd2e14bc2d0f67df235d405c24b9c11a51.zip
Crap out on nonzero MDA return status.
svn path=/trunk/; revision=235
Diffstat (limited to 'fetchmail.c')
-rw-r--r--fetchmail.c24
1 files changed, 16 insertions, 8 deletions
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);