From: epg <> Date: Fri, 6 Sep 2002 07:19:16 +0000 (+0000) Subject: (main): If running the optional program on the newly delivered message X-Git-Url: https://diplodocus.org/git/mdeliver/commitdiff_plain/59a8df098090a545c1b54fe1415524a8dd771e5c?hp=4140b150adbbb1e081b4b8d5ae6980394517cc85 (main): If running the optional program on the newly delivered message fails, save errno before getting to work on creating an error file. --- diff --git a/mdeliver.c b/mdeliver.c index 5d4b900..7706aa5 100644 --- a/mdeliver.c +++ b/mdeliver.c @@ -252,6 +252,7 @@ main(int argc, char *argv[]) pid_t pid; FILE *errfile; char *fail; + int olderrno; int fd; if (argv[1] && argv[1][0] == '-' && argv[1][1] == 'v') { @@ -280,6 +281,7 @@ main(int argc, char *argv[]) } else { fail = "fork"; } + olderrno = errno; /* If we got here fork or exec failed, so try to write an * error message where later mail processors can find it. We @@ -289,7 +291,7 @@ main(int argc, char *argv[]) fd = open(newfn, O_WRONLY | O_EXCL | O_CREAT, 0644); errfile = fdopen(fd, "w"); if (errfile) { - fprintf(errfile, "%s:%d\n", fail, errno); + fprintf(errfile, "%s:%d\n", fail, olderrno); } }