Terminates the process.
(self)
| 1665 | raise ValueError("Unsupported signal: {}".format(sig)) |
| 1666 | |
| 1667 | def terminate(self): |
| 1668 | """Terminates the process.""" |
| 1669 | # Don't terminate a process that we know has already died. |
| 1670 | if self.returncode is not None: |
| 1671 | return |
| 1672 | try: |
| 1673 | _winapi.TerminateProcess(self._handle, 1) |
| 1674 | except PermissionError: |
| 1675 | # ERROR_ACCESS_DENIED (winerror 5) is received when the |
| 1676 | # process already died. |
| 1677 | rc = _winapi.GetExitCodeProcess(self._handle) |
| 1678 | if rc == _winapi.STILL_ACTIVE: |
| 1679 | raise |
| 1680 | self.returncode = rc |
| 1681 | |
| 1682 | kill = terminate |
| 1683 |
no test coverage detected