Program A executes program B.
You want to debug program B.
B exits before you can attach your debugger.
Insert an infinite loop in main() in program B:
Run program A.
Attach debugger to program B.
Set the program counter to the next line:
In gdb, use the "jump" command.
In Visual Studio, use the "Set next statement" command on the context menu.