()
| 194 | |
| 195 | |
| 196 | def wait_for_exit(): |
| 197 | try: |
| 198 | code = process.wait() |
| 199 | if sys.platform != "win32" and code < 0: |
| 200 | # On POSIX, if the process was terminated by a signal, Popen will use |
| 201 | # a negative returncode to indicate that - but the actual exit code of |
| 202 | # the process is always an unsigned number, and can be determined by |
| 203 | # taking the lowest 8 bits of that negative returncode. |
| 204 | code &= 0xFF |
| 205 | except Exception: |
| 206 | log.swallow_exception("Couldn't determine process exit code") |
| 207 | code = -1 |
| 208 | |
| 209 | log.info("{0} exited with code {1}", describe(), code) |
| 210 | output.wait_for_remaining_output() |
| 211 | |
| 212 | # Determine whether we should wait or not before sending "exited", so that any |
| 213 | # follow-up "terminate" requests don't affect the predicates. |
| 214 | should_wait = any(pred(code) for pred in wait_on_exit_predicates) |
| 215 | |
| 216 | try: |
| 217 | launcher.channel.send_event("exited", {"exitCode": code}) |
| 218 | except Exception: |
| 219 | pass |
| 220 | |
| 221 | if should_wait: |
| 222 | _wait_for_user_input() |
| 223 | |
| 224 | try: |
| 225 | launcher.channel.send_event("terminated") |
| 226 | except Exception: |
| 227 | pass |
| 228 | |
| 229 | |
| 230 | def _wait_for_user_input(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…