Debugging a C child process using Eclipse

When we are debugging an application that uses C forks in Eclipse, by default the debugger is not configured to follow into the forked child process. Entering set follow-fork-mode child into the console has no effect.

A workaround for this is to create a .gdbinit file that contains set follow-fork-mode child in the project root folder. In the Eclipse gdb preferences, ensure that this is referenced by the setting for "GDB command file".

Note: A more flexible option (as it should ask at each fork) is: set follow-fork-mode ask. I have not tried this out in Eclipse though, and unfortunately not all gdb command line instructions work in Eclipse.