5

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)

smci
  • 32,567
  • 20
  • 113
  • 146
Ryan
  • 4,179
  • 6
  • 30
  • 31

1 Answers1

1

Windows doesn't have the unix signals IPC mechanism.

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

drudru
  • 4,933
  • 1
  • 19
  • 19
  • According to the link below, you can't send CTRL+C ?? – Ryan Jul 08 '09 at 01:17
  • 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 Jul 08 '09 at 17:00
  • 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 Jul 09 '09 at 20:50
  • 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 Jul 10 '09 at 00:14
  • 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 Jul 10 '09 at 00:58
  • Ok, that is very helpful. Is there any console associated with these processes? Are all the processes in a process group? – drudru Jul 10 '09 at 21:56
  • 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 Jul 11 '09 at 01:54
  • Creation flags docs here: http://msdn.microsoft.com/en-us/library/ms684863(VS.85).aspx – Ryan Jul 11 '09 at 01:54