summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-06-28 21:57:59 -0400
committerPaul Smith <psmith@gnu.org>2013-06-28 21:57:59 -0400
commit9453a7451d66ee1ea5762a75161bf8a818c01a1f (patch)
treefc76410d37ff3b464dd1da10a4ab4b90e1331354 /main.c
parent5e7bf7c554317849610173845871ae7d6a130ffe (diff)
downloadgunmake-9453a7451d66ee1ea5762a75161bf8a818c01a1f.tar.gz
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.
Diffstat (limited to 'main.c')
-rw-r--r--main.c6
1 files changed, 6 insertions, 0 deletions
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)