The forked process gets a copy of the variable memory, and at the time of the fork the output buffer has yet to be flushed. No output has been written to the console when you fork, only buffered up. Both processes thus continues with text1 already in the buffer, and thus both print it.