]> diplodocus.org Git - mdeliver/commitdiff
(main): If running the optional program on the newly delivered message
authorepg <>
Fri, 6 Sep 2002 07:19:16 +0000 (07:19 +0000)
committerepg <>
Fri, 6 Sep 2002 07:19:16 +0000 (07:19 +0000)
fails, save errno before getting to work on creating an error file.

mdeliver.c

index 5d4b900..7706aa5 100644 (file)
@@ -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);
         }
     }