Hi,
Mentioned in Stevens & Rago "Advanced Programming in the UNIX"
I don't understand why must flush all line-buffered output streams when (a)an unbuffered or (b)a line-buffered stream require data from kernel?
Hi,
Mentioned in Stevens & Rago "Advanced Programming in the UNIX"
I don't understand why must flush all line-buffered output streams when (a)an unbuffered or (b)a line-buffered stream require data from kernel?
What if you're using both ends of a pipe? If you write to one end and it ends up in a buffer, then you try to read it from the other end, it'll hang until something flushes it.
The behavior mentioned in that Stevens quote exists in many c stdio implementations to ensure that prompts without a newline have been emitted before input is read. I don't believe that's standardized even though it's probably common behavior. It's best to use an explicit fflush as necessary.
Regards,
Alister