Terminates the process.
(self)
| 1752 | raise ValueError("Unsupported signal: {}".format(sig)) |
| 1753 | |
| 1754 | def terminate(self): |
| 1755 | """Terminates the process.""" |
| 1756 | # Don't terminate a process that we know has already died. |
| 1757 | if self.returncode is not None: |
| 1758 | return |
| 1759 | try: |
| 1760 | _winapi.TerminateProcess(self._handle, 1) |
| 1761 | except PermissionError: |
| 1762 | # ERROR_ACCESS_DENIED (winerror 5) is received when the |
| 1763 | # process already died. |
| 1764 | rc = _winapi.GetExitCodeProcess(self._handle) |
| 1765 | if rc == _winapi.STILL_ACTIVE: |
| 1766 | raise |
| 1767 | self.returncode = rc |
| 1768 | |
| 1769 | kill = terminate |
| 1770 |
no test coverage detected