Is this a Linux implementation detail, or is it a feature of POSIX systems generally?
POSIX says that stderr shouldn't be "fully buffered" https://pubs.opengroup.org/onlinepubs/9699919799/functions/s... but I believe that allows for line buffering. Its terminology can be found here: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/st... (look for _IOFBF).
Re:Why stdout is faster than stderr?
by thesuitonym on Wednesday January 10, 2024 @02:53PM
(#38942340)
OpenBSD's stderr seems to be buffered, so it may just be a Linux thing.
That page says the opposite:
> Initially, the standard error stream is unbuffered.
Re:Why stdout is faster than stderr?
by thesuitonym on Friday January 12, 2024 @05:25PM
(#38974978)
I have no idea how I read that so wrong. Mea culpa.
Notes
The stream stderr is unbuffered. The stream stdout is line-buffered when it points to a terminal. Partial lines will not appear until fflush(3) or exit(3) is called, or a newline is printed. This can produce unexpected results, especially with debugging output. The buffering mode of the standard streams (or any other stream) can be changed using the setbuf(3) or setvbuf(3) call. Note that in case stdin is associated with a terminal, there may also be input buffering in the terminal driver, entirely unrelated to stdio buffering. (Indeed, normally terminal input is line buffered in the kernel.) This kernel input handling can be modified using calls like tcsetattr(3); see also stty(1), and termios(3).