As I understood fork() creates a child process by copying the image of the parent process.
My question is about how do child and parent processes share the stdout stream?
Can printf() function of one process be interrupted by other or not? Which may cause the mixed output.
Or is the printf() function output atomic?
For example:
The first case:
parent: printf("Hello");
child: printf("World\n");
Console has: HeWollorld
The second case:
parent: printf("Hello");
child: printf("World\n");
Console has: HelolWorld