You should not do this. Your C library will assume that the process has exclusive access to the standard IO buffer area, and will only mediate between threads of that process, no doubt using a mutex not in anonymous mmap
. So you risk undefined behaviour if that buffer space is altered, just as if you wrote over it yourself.
However, a better question is why on earth would you want to do this? Why not make the buffer area /not/ shared (e.g. by using malloc()
to allocate it), then everything will work fine.