Is setvbuf on STDOUT safe for other processes?

I am using HP-UX. I want to disable buffering on stdout to ensure that every line of code is printed in case of a main dump using the command below:

setvbuf(stdout, NULL, _IONBF, 0); // turn off buffering for stdout 

In this case, does printing on stdout, which is redirected to some log file also affect other processes? I want to know if this change is only local to the running process or not. Also, is it possible to disable buffering in the process and then set it _IO_FBF in code again? (fflush before each call)

PS: I know that this will disable buffering and degrade I / O performance, but I want to do this for debugging purposes only.

+4
source share
1 answer

The setvbuf call only affects stdio procedures in the current process and any child fork'd, but not exec'd.

How stdio answers when setvbuf is called several times in the same thread is not specified in the C standard, so do not issue a few calls in the code that you want to port through C implementations.

0
source

Source: https://habr.com/ru/post/1389296/


All Articles