Debugging fork()'ing processes with gdb(1) ========================================== Lukas Fleischer I ran into the issue of debugging fork()'ing programs today when helping someone to debug a helper program of the GNOME Session Manager that crashed unexpectedly, printing "Failed to execute child process: [...]" to stderr. Digging deeper into the code, it emerged that the error occured in a Glib2 function called fork_exec_with_pipes() that uses a double fork() and subsequently execv()'s in the child process. As everything seemed to originate from the execv() syscall, we needed to find a way to debug those child processes. To sum up, there's actually two obvious ways of achieving this: 1. "attach $pid" to the new process. Not feasible if you need to debug the child process just in time. 2. "set follow-fork-mode child" makes gdb follow child processes whenever a program fork()s. Use "set follow-fork-mode parent" to switch back to the default behaviour. "set follow-fork-mode ask" can be used if you want to be prompted on every single fork().