It bugs me to debug multiprocess C programs by using GDB. Here is a note for multi processing, and multithreaded debugging.
set follow-fork-mode child set schedule-multiple on set detach-on-fork off b ## r
## means a number, in this case, line number.
Switching between processes:
info inferiors inferior #
In this case, # means process number.
info threads thread #
Please consult the official docs for more features.