Are you asking how to break into a debugger when child process procA creates the handle to logB? I'll assume that you're using Windows since you mentioned Process Explorer.
One way to do this is to use the Image File Execution Options
registry key to specify that every time procA.exe
is started, you want to launch the debugger. When the debugger starts, you can set a breakpoint in the code that creates the handle to logB and then let the process continue. This works with any debugger (such as WinDbg or ntsd, or profiling tools such as AQTime), not just Visual Studio.
Another way to do this is to tell the debugger to attach to all child processes. There are several ways to enable this behavior with WinDbg or ntsd. That way, you attach the debugger to the parent process, and it will auto-attach to child process procA, and you can set a breakpoint in the appropriate code.
Yet another way is to temporarily modify your code to generate a breakpoint exception using the DebugBreak()
function when it creates the handle to logB, then attach a debugger using just-in-time debugging. Note that if your code handles structured exceptions without an exception filter expression (which is a bad idea), this won't work, and may have surprising results (deadlock, memory leak, etc.).