From 9453a7451d66ee1ea5762a75161bf8a818c01a1f Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 28 Jun 2013 21:57:59 -0400 Subject: Set O_APPEND mode for stdout/stderr and output-sync temporary files. POSIX does not guarantee that writes will be atomic if a file is opened for normal (non-append) output. That means if multiple processes are writing to the same file, output could be lost. I can't think of a real use-case where we would NOT want append for stdout/stderr, so force it if we can. --- main.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'main.c') diff --git a/main.c b/main.c index fe8d355..83a95db 100644 --- a/main.c +++ b/main.c @@ -1195,6 +1195,12 @@ main (int argc, char **argv, char **envp) setlinebuf (stdout); #endif /* setlinebuf missing. */ + /* Configure stdout/stderr to be in append mode. + This keeps parallel jobs from losing output due to overlapping writes. */ + + set_append_mode (fileno (stdout)); + set_append_mode (fileno (stderr)); + /* Figure out where this program lives. */ if (argv[0] == 0) -- cgit v1.2.3