As we know, STDOUT is buffered in Linux. My question is: 1) is it a global buffer shared by all processes? or one buffer for each process? 2) where the buffer is? on stack, or heap or static area? 3) who creates it?
stdout
is a C FILE
pointer created by the standard library, so the relevant code is loaded as part of your C library. On Linux, it will be implemented in terms of Posix file descriptors.
Both your C library and the kernel may use buffering; you'll have to check the individual documentations. I recommend to start by looking at the relevant part of the source code of the C library (i.e. the part that implements <stdio.h>
), which should be very educational.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With