aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-06-25 00:46:02 +0200
committerLars Ingebrigtsen2019-06-25 00:46:20 +0200
commit630e01a70312d8e6ad47aeba370228fc05c789a9 (patch)
tree065a39d844b4f3132423d8cae03485946c0a058b /src
parentf70cdd4caa38602f908f106352f2135964e7bd92 (diff)
downloademacs-630e01a70312d8e6ad47aeba370228fc05c789a9.tar.gz
emacs-630e01a70312d8e6ad47aeba370228fc05c789a9.zip
Make message_to_stderr do one single fwrite
* src/xdisp.c (message_to_stderr): When running as a batch process, the output from `message' goes to stderr, and has a newline appended. Rewrite the code so that only one fwrite is performed to enable messages that are shorter than PIPE_BUF (usually 4096 on modern operating systems) are written out as one chunk, as this will ensure that the messages are not interleaved with messages from other processes that are writing at the same time. This does not affect other stderr outputs, just the ones from `message'.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 5d70440f1cb..25e8932945e 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10705,10 +10705,22 @@ message_to_stderr (Lisp_Object m)
10705 else 10705 else
10706 s = m; 10706 s = m;
10707 10707
10708 fwrite (SDATA (s), SBYTES (s), 1, stderr); 10708 /* We want to write this out with a single fwrite call so that
10709 output doesn't interleave with other processes writing to
10710 stderr at the same time. */
10711 {
10712 int length = min (INT_MAX, SBYTES (s) + 1);
10713 char *string = xmalloc (length);
10714
10715 memcpy (string, SSDATA (s), length - 1);
10716 string[length - 1] = '\n';
10717 fwrite (string, 1, length, stderr);
10718 xfree (string);
10719 }
10709 } 10720 }
10710 if (!cursor_in_echo_area) 10721 else if (!cursor_in_echo_area)
10711 fputc ('\n', stderr); 10722 fputc ('\n', stderr);
10723
10712 fflush (stderr); 10724 fflush (stderr);
10713} 10725}
10714 10726