summaryrefslogtreecommitdiff
path: root/src/sum.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sum.c')
-rw-r--r--src/sum.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/sum.c b/src/sum.c
index 91d7f34ba..f0e0cc09a 100644
--- a/src/sum.c
+++ b/src/sum.c
@@ -233,6 +233,10 @@ main (int argc, char **argv)
atexit (close_stdout);
+ /* Line buffer stdout to ensure lines are written atomically and immediately
+ so that processes running in parallel do not intersperse their output. */
+ setvbuf (stdout, NULL, _IOLBF, 0);
+
have_read_stdin = false;
while ((optc = getopt_long (argc, argv, "rs", longopts, NULL)) != -1)