Well, gdb will do what you tell it to, with:
set follow-fork-mode <parent|child>
By default - it follows the parent.
You should set this attribute before your program calls fork, of-course.
The process not being followed - will continue running normally.
Tough luck - cannot follow both...
...or can we? on Linux we can - see below..
...on other platforms you could follow parent, make child sleep (e.g.
, and attach to child with another gdb instance.
Originally written by