Writing Software, technology, sysadmin war stories, and more. Tuesday, August 19, 2014 Ah, fork(). The way processes make more processes. Well, one of them, anyway. It seems I have another story to tell about it. It can fail. Got that? Are you taking this seriously? You should. fork can fail. Just like malloc, it can fail. Neither of them fail often, but when they do, you can't just ignore it. You have to do something intelligent about it. People seem to know that fork will return 0 if you're the child and some positive number if you're the parent -- that number is the child's pid. They sock this number away and then use it later. Guess what happens when you don't test for failure? Yep, that's right, you probably treat "-1" (fork's error result) as a pid. That's the beginning of the pain. The true pain comes later when it's time to send a signal. Maybe you w...