What sort of merging are you trying to do? How big are the files your primary program writes to disk?, are the individual files already sorted? Do you need to merge them in sorted order? I think, outside of the fork/exec pointers and discussion, some requirements about what the program needs to do might help with the overall answer.