24

I'm using Eclipse on Windows, with the PyDev plugin for Python development. When I use 'Run' to start my application, it spawns a new Python (CPython) instance. When I use the 'terminate' button (red square), it kills the process. However, it appears to do a SIGKILL, so my shutdown handler is unable to clean up.

Is there any way to get Eclipse to send a SIGTERM, or simulate a keyboard interrupt (ctrl-c) from the Eclipse console?

Note: I'm aware there are other Python IDEs like Komodo or Wing that might solve this problem, but I'm not looking to switch over this.

DNS
  • 37,249
  • 18
  • 95
  • 132

2 Answers2

11

Eclipse uses the Java Process API which sends the signal. This is a native API and there is no way to change that. I assume that you've tried to install a handler for SIGKILL, too, and that didn't work.

Therefore, the only solution would be to write a small batch file which lists the processes and sends SIGTERM to one of them. Invoke that from a command prompt. If you use Alt-Tab to switch to it, it's almost as comfortable as doing it from inside Eclipse.

Or write a plugin to invoke batch files.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • 7
    Installing a handler for SIGKILL is pointless as it will, by definition, never execute. SIGTERM asks a program to terminate. SIGKILL causes the OS to forcibly terminate a program without informing it in advance. – Powerlord Mar 24 '09 at 16:24
  • Bemrose: I guessed as much but was too lazy to look that up :) – Aaron Digulla Mar 24 '09 at 16:29
2

I looked at How can a Java program get its own process ID? and came up with this.

System.out.println("kill -SIGINT "+ProcessHandle.current().pid());

I realize this isn't ideal if you don't want it printing this out for production but if you're just prototyping it's handy. Or you could put it inside an if that only runs if you're debugging.

silverduck
  • 401
  • 6
  • 9