Terminates the process.
(self)
| 1698 | raise ValueError("Unsupported signal: {}".format(sig)) |
| 1699 | |
| 1700 | def terminate(self): |
| 1701 | """Terminates the process.""" |
| 1702 | # Don't terminate a process that we know has already died. |
| 1703 | if self.returncode is not None: |
| 1704 | return |
| 1705 | try: |
| 1706 | _winapi.TerminateProcess(self._handle, 1) |
| 1707 | except PermissionError: |
| 1708 | # ERROR_ACCESS_DENIED (winerror 5) is received when the |
| 1709 | # process already died. |
| 1710 | rc = _winapi.GetExitCodeProcess(self._handle) |
| 1711 | if rc == _winapi.STILL_ACTIVE: |
| 1712 | raise |
| 1713 | self.returncode = rc |
| 1714 | |
| 1715 | kill = terminate |
| 1716 |