From: epg <> Date: Fri, 13 Sep 2002 01:49:16 +0000 (+0000) Subject: (run_processor): While there's nothing we can do if any of the X-Git-Url: https://diplodocus.org/git/mdeliver/commitdiff_plain/29da9e52a0d69c424bcf365cdcdf1b571618026c (run_processor): While there's nothing we can do if any of the 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). --- diff --git a/mdeliver.c b/mdeliver.c index 68b8691..340e1e9 100644 --- a/mdeliver.c +++ b/mdeliver.c @@ -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); - 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); } }