mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
pexpect: Check if the process exited with a signal
This would have been helpful in #10044: > signals.py:28: SIGNAL SIGSEGV from expect_prompt() instead of "EOF".
This commit is contained in:
parent
f8e38819a5
commit
7a22dcb687
@ -22,6 +22,7 @@ import re
|
||||
import sys
|
||||
import time
|
||||
import pexpect
|
||||
from signal import Signals
|
||||
|
||||
# Default timeout for failing to match.
|
||||
TIMEOUT_SECS = 5
|
||||
@ -246,8 +247,15 @@ class SpawnedProc(object):
|
||||
Report it to stdout, along with the offending call site.
|
||||
If 'unmatched' is set, print it to stdout.
|
||||
"""
|
||||
# Close the process so we can get the status
|
||||
self.spawn.close()
|
||||
colors = self.colors()
|
||||
failtype = pexpect_error_type(err)
|
||||
# If we get an EOF, we check if the process exited with a signal.
|
||||
# This shows us e.g. if it crashed
|
||||
if failtype == 'EOF' and self.spawn.signalstatus != 0:
|
||||
failtype = "SIGNAL " + Signals(self.spawn.signalstatus).name
|
||||
|
||||
fmtkeys = {"failtype": failtype, "pat": escape(pat)}
|
||||
fmtkeys.update(**colors)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user