You understood the sentence correctly, but ...
When you call fork , it takes a snapshot of the process and creates an exact duplicate. Therefore, if there is data in the stdout buffer waiting to be written to the console, then this data will be in the child output buffer after fork, as well as in the parent buffer.
There are two ways to clear the output buffer in front of the plug. You can add a new line \n at the end of printf
printf( "before\n" ); fork(); printf( "after\n" );
or you can use fflush function
printf( "before " ); fflush( stdout ); fork(); printf( "after " );
source share