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

From: Eli Zaretskii <[email-masked]>
Date: Thu, 11 Feb 2021 16:09:28 +0200

> From: Ioannis Kappas <[email-masked]>
> Date: Thu, 11 Feb 2021 08:10:34 +0000
> Cc: [email-masked]
> 
> > My reading of the code is that we already fflush stderr after emitting
> > a message, so this should already happen.  See message_to_stderr.  If
> > that still doesn't help, then there's some buffering in the OS (for
> > example, in the pipe machinery itself), which we cannot control.
> 
> the xdisp.c:message_to_stderr() is the first function i studied with
> gdb when I started the investigation. Unless I've missed something,
> it does not seem to lead to calling fflush (under windows at least):

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'?