There is a complex set of rules POSIX defines (1003.1-1996 8.2.3, p 212) for what is legal in these situations. The short version is that the program should do fflush before fork, or use only _exit in the child. (Various other things are acceptable too, but they are all other things that amount to having recently flushed buffers before fork.)