views:

587

answers:

2

I've got a python script managing a gdb process on windows, and I need to be able to send a SIGINT to the spawned process in order to halt the target process (managed by gdb)

It appears that there is only SIGTERM available in win32, but clearly if I run gdb from the console and Ctrl+C, it thinks it's receiving a SIGINT. Is there a way I can fake this such that the functionality is available on all platforms?

(I am using the subprocess module, and python 2.5/2.6)

+1  A: 

Windows doesn't have the unix signals IPC mechanism.

I would look at sending a CTRL-C to the gdb process.

drudru
According to the link below, you can't send CTRL+C ??
Ryan
I would send the fake key sequence to the GDB process. Sort of like a Macro program. It is definitely not pretty.Another option is to instrument the gdb process with a reliable win32 IPC mechanism.
drudru
Fake key sequence doesn't work. It's not GDB that processes the key sequence into an interrupt. The shell catches the CTRL+C, and then turns it into some sort of IPC event that's picked up by gdb and interpreted as a SIGINT (even though windows as we know it doesn't have SIGINT)When you say "instrument the gdb process with a reliable win32 IPC mchanism" you mean actually much around in the GDB code right? Like actually go and drop in a named pipe or some flag or something that I could set externally? Let's assume that is also not an option in this case.
Ryan
Ok, let me try to figure this out. It is interesting. So you have a python process that starts a GDB process that starts its own target process. You want to have the python process cause a break or interuption to occur in the windows process.I need to know a little more. Is the target process any windows process or ones that were compiled with Cygwin. Which GDB is this (Cygwin, a custom one, etc)? This will help me help you zone in on the answer. Cheers.
drudru
What I'm writing is a frontend for GDB, so it could potentially be any of the above. The GDB I'm working with now (the one that's giving me fits) is codesourcery g++, ( http://www.codesourcery.com/ ) Which appears to be built using the MinGW system. The idea is to allow people to use any GDB they like, so a cygwin binary, or a mingW thing or whatever are all on the table. I've also tested a simple case by using MinGW gcc to build a simple executable that just prints a counter until it "recieves SIGINT" at which time it prints a message indicating so. I get the same behavior with it.
Ryan
Ok, that is very helpful. Is there any console associated with these processes? Are all the processes in a process group?
drudru
I haven't been able to get anything to work, either allowing the subprocess to inherit the parent's console, or using the creationflags argument to do a whole variety of things, including creating a new console, creating the process as a "detached" process, and starting it in a new process group. (Some of these methods are explained in the link below, while still being almost completely unhelpful)
Ryan
Creation flags docs here: http://msdn.microsoft.com/en-us/library/ms684863(VS.85).aspx
Ryan
+1  A: 

http://objectmix.com/python/387639-sending-cntrl-c.html

This is helpful. I've got other problems now.

Ryan