[OT]-ish: Can someone explain this?

Randy J. Ray rjray at blackperl.com
Sat Jul 2 22:07:08 BST 2011

On 07/02/2011 10:04 AM, Andrew Suffield wrote:
> On Sat, Jul 02, 2011 at 05:32:38PM +0100, Dirk Koopman wrote:
>> But how come I get output at a shell prompt, and not down a pipe (or
>> a redirection either)? What special magic is occurring here?
> If:
> 1. isatty() is true on the underlying fd of the FILE*
> and:
> 2. The string contains \n
> then printf calls fflush().
> In your first instance, stdout was your terminal, and in the second it
> was one end of a pipe.

That was my first thought, but I wasn't 100% sure. Glad to see I was right, and 
haven't *completely* forgotten my C minutiae...

Randy J. Ray      Sunnyvale, CA      http://www.rjray.org   rjray at blackperl.com
Silicon Valley Scale Modelers: http://www.svsm.org

More information about the london.pm mailing list