I have a question about the buffering in standard library for I/O:
I read “The Linux Programming Interface” chapter 13 about File I/O buffering, the author mentioned that standard library used I/O buffering for disk file and terminal.
My question is that does this I/O buffering also apply to FIFO, pipe, socket and network file?
I have a question about the buffering in standard library for I/O: I read
Share
Yes, if you’re using the
FILE *based standard I/O library. The only odd thing that might happen is if the underlying system file descriptor returns non-zero for theisattyfunction. Then stdio might ‘line buffer’ both input and output. This means it tends to flush when it sees a'\n'.I believe that it’s required to line buffer
stdoutif file descriptor 1 returns non-zero forisatty.