In addition to obvious -1 check, one should never exit() nor return from main() if fork() returned zero. Sorry that I didn't care to note that, but one doesn't explain all fork() subtleties in a single sentence. If interested, refer to APUE or similar book.
Forks are too sharp for children, if you like that pun.
Forks are too sharp for children, if you like that pun.