From: Al S. <al...@al...> - 2002-09-13 21:59:43
|
> The problem as I see it, is that gdb does not break the chain of > inheretance. Is this right? You wouldn't think so. Gdb does not set STARTF_USESTDHANDLES in STARTUPINFO. Gdb does pass true for the inherit-handles flag, but I changed that to false with no change in the behavior. In other words, with that change, gdb should not allow a created process to inherit any handles no matter what they are. However ... > So, to ensure that gdb does not pass on the handles for your pipe to the > debugged app, the std handles need to be invalidated. So the launch code in > gdb would need to be something like:- [snip code] > This is just about the easiest way I can think of getting the required > behaviour. But it does work. Skeptically, I added your statements verbatim to gdb. And, by golly, it fixed the problem. If you ever get to my part of Florida, or if I get to your home, I'll buy you the best dinner in town. Well, not exactly verbatim. I had to add entries for the stdin handle. But you can still have dessert. Conclusion: The win32 debugger api under 9x and ME causes a target console application to inherit the debugging program's stdin/stdout/stderr handles even when you tell it not to. It is necessary to modify gdb to make it work in this environment. The resulting gdb program does not work properly from the console unless you use the set new-console command. That is, target console input output does not work without new-console. Because of that, I don't plan to submit a patch. I'll include the changed source code with whatever I distribute to remain compliant, however. If anyone wants to see what I did, perhaps to add a command to gdb to support this mode of operation, I'll send the source code to them. Unless you prefer otherwise I'd like to give credit to you and the others here who made suggestions. I plan to write about this episode in an upcoming issue of Dr. Dobb's Journal. (Plus, if you all come to town on the same day, we'll have a party at my house.) (a very tired and happy) Al Stevens Dr. Dobb's Journal |