Subject: Re: bug#46388: 27.1; emacs -batch does not output messages immediately when invoked outside of the command prompt

From: Paul Eggert <[email-masked]>
Date: Thu, 11 Feb 2021 13:15:42 -0800

On 2/11/21 6:09 AM, Eli Zaretskii wrote:
> Then maybe this:
> 
>> /* Return the error output stream.  */
>> static FILE *
>> errstream (void)
>> {
>>    FILE *err = buferr;
>>    if (!err)
>>      return stderr;
>>    fflush_unlocked (stderr);  <<<<<<<<<<<<<<<<
>>    return err;
>> }
> should be fixed to fflush 'buferr' instead (or in addition to stderr)?
> 
> Paul, isn't that a bug that we fflush stderr here, and not 'buferr'?

No, it's intended. The goal of 'errstream' is to flush out all the stuff 
written to stderr, before outputting anything sent to buferr. There is 
no need to fflush buferr here, since it's gonna be flushed soon anyway 
when a newline is output.

Functions like message_to_stderr etc. are supposed to do a series of 
calls to one or more functions like errwrite that end with outputting a 
newline, without invoking any code that outputs directly to stderr. This 
is explained in the comment before sysdep.c's errputc function, a 
comment that could perhaps be improved.