Print signal messages (closes #955)

This commit is contained in:
Ryan Gonzalez 2016-05-20 14:42:40 -05:00
parent 42c8c02bc7
commit ac806c13bd

View file

@ -41,6 +41,17 @@ AT_EXIT_SIGNALS = (signal.SIGABRT, signal.SIGFPE, signal.SIGILL, signal.SIGSEGV,
if ON_POSIX:
AT_EXIT_SIGNALS += (signal.SIGTSTP, signal.SIGQUIT, signal.SIGHUP)
SIGNAL_STRINGS = {
signal.SIGABRT: 'Aborted',
signal.SIGFPE: 'Floating point exception',
signal.SIGILL: 'Illegal instructions',
signal.SIGTERM: 'Terminated',
signal.SIGSEGV: 'Segmentation fault',
signal.SIGQUIT: 'Quit',
signal.SIGHUP: 'Hangup',
signal.SIGKILL: 'Killed'
}
def resetting_signal_handle(sig, f):
"""Sets a new signal handle that will automatically restore the old value
@ -599,6 +610,16 @@ def run_subproc(cmds, captured=False):
errout = errout.replace('\r\n', '\n')
procinfo['stderr'] = errout
if prev_proc.signal:
sig, core = prev_proc.signal
try:
sig_str = SIGNAL_STRINGS[sig]
except KeyError:
pass
else:
if core:
sig_str += ' (core dumped)'
print(sig_str)
if (not prev_is_proxy and
hist.last_cmd_rtn is not None and
hist.last_cmd_rtn > 0 and