I guessed as much. I’m not alone - there is a whole chapter on this topic in “The art of UNIX programming”.