I'm trying to debug a low-level C program in gdb. The program in question is meant to act as a wrapper, launching another process and monitoring/interfering with its memory use.
When I load the program in gdb, everything seems normal (if not ideal) at first. I see the new process fork, and then it hangs. In and of itself, this wouldn't be too strange; likely a deadlock or an infinite loop somewhere in my code.
But if I interrupt and kill the process within gdb, and then run it again within the same gdb session, everything works perfectly fine. It takes about half a second to run and acts exactly as it should.
So my question is: What is gdb preserving between runs of my program? What would change between the first and second execution?