Coupling of stdin and stdout

Shaun Jackman sjackman@gmail.com
Wed May 10 20:46:00 GMT 2006


On 5/10/06, Shaun Jackman <sjackman@gmail.com> wrote:
> What is the mechanism whereby reading from stdin causes stdout to be flushed?
>
> Cheers,
> Shaun

Ah, found it.

libc/stdio/refill.c (__srefill):
  /*
   * Before reading from a line buffered or unbuffered file,
   * flush all line buffered output files, per the ANSI C
   * standard.
   */

  if (fp->_flags & (__SLBF | __SNBF))
    _CAST_VOID _fwalk (_GLOBAL_REENT, lflush);


More information about the Newlib mailing list