Eli Zaretskii wrote: > I'm okay with making 'message' write in one go to stderr, but I don't > want to pay the price of having stderr buffered globally. I came up with a fix that does all that. Although the fix does not alter the buffering of the stderr stream, it causes 'message' and similar functions to write in one go to avoid interleaving output. It also fixes the problem on AIX and Solaris where a single call to fprintf is implemented by multiple calls to 'write' even if the diagnostic is short, botching interleaving. It also fixes the INT_MAX overflow and memory-allocation issues of the current master's implementation of 'message'. Proposed patches attached. The first one merely refactors and simplifies the C-level code, without changing behavior; this simplifies later patches. The second patch fixes buffering of most C-level diagnostics in Emacs, so that they interleave well with other processes' diagnostics. The third patch similarly fixes buffering of most Lisp-level diagnostics in Emacs. The last patch is one more simplification of the C code. I still far prefer the three-line patch I submitted earlier, as it was much simpler and the objections to it were theoretical (i.e., not based on actual Emacs code). However, the attached patches work nearly as well, and they do so while obeying the constraints you imposed on fixing the problem.