()
| 176 | |
| 177 | |
| 178 | def kill(): |
| 179 | if process is None: |
| 180 | return |
| 181 | |
| 182 | try: |
| 183 | if process.poll() is None: |
| 184 | log.info("Killing {0}", describe()) |
| 185 | # Clean up the process tree |
| 186 | if sys.platform == "win32": |
| 187 | # On Windows, kill the job object. |
| 188 | winapi.kernel32.TerminateJobObject(job_handle, 0) |
| 189 | else: |
| 190 | # On POSIX, kill the debuggee's process group. |
| 191 | os.killpg(process.pid, signal.SIGKILL) |
| 192 | except Exception: |
| 193 | log.swallow_exception("Failed to kill {0}", describe()) |
| 194 | |
| 195 | |
| 196 | def wait_for_exit(): |