As noted by kib@:
Using printf around fork is not the best idea, and definitely should not
be provided as a guiding example in the man page. Using stdio safely around
fork() requires at least flushing buffers and ensuring that opened FILEs are
in some consistent state right at fork.
It would work by chance in your example, mostly because you did not use
anything in stdio before fork, but any further changes would result in
very puzzling bugs (for beginners, who are the target of this example).
Reported by: kib