]> diplodocus.org Git - mdeliver/commitdiff
(run_processor): While there's nothing we can do if any of the
authorepg <>
Fri, 13 Sep 2002 01:49:16 +0000 (01:49 +0000)
committerepg <>
Fri, 13 Sep 2002 01:49:16 +0000 (01:49 +0000)
err-file-writing steps fail, there's no reason we can't be a little
more careful in doing it.  Do so (including using fflush, fsync,
and close).

mdeliver.c

index 68b8691..340e1e9 100644 (file)
@@ -279,9 +279,14 @@ run_processor(char *newfn)
     memcpy(newfn, "err", 3);
     mkdir("err", 0700);
     fd = open(newfn, O_WRONLY | O_EXCL | O_CREAT, 0644);
     memcpy(newfn, "err", 3);
     mkdir("err", 0700);
     fd = open(newfn, O_WRONLY | O_EXCL | O_CREAT, 0644);
-    errfile = fdopen(fd, "w");
-    if (errfile) {
-        fprintf(errfile, "%s:%d\n", fail, olderrno);
+    if (fd >= 0) {
+        errfile = fdopen(fd, "w");
+        if (errfile) {
+            fprintf(errfile, "%s:%d\n", fail, olderrno);
+            fflush(errfile);
+        }
+        fsync(fd);
+        close(fd);
     }
 }
 
     }
 }