diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index d8c080b..1bce9c1 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -2239,10 +2239,8 @@ class InteractiveShell(SingletonConfigurable): cmd = py3compat.unicode_to_str(cmd) # Call the cmd using the OS shell, instead of the default /bin/sh, if set. ec = subprocess.call(cmd, shell=True, executable=os.environ.get('SHELL', None)) - # Returns either the exit code or minus the value of the signal number. - # See the docs for subprocess.Popen.returncode . - if ec < 0: - ec = -ec + # exit code is positive for program failure, or negative for + # terminating signal number. # We explicitly do NOT return the subprocess status code, because # a non-None value would trigger :func:`sys.displayhook` calls. diff --git a/IPython/utils/_process_posix.py b/IPython/utils/_process_posix.py index baf7c24..bb35225 100644 --- a/IPython/utils/_process_posix.py +++ b/IPython/utils/_process_posix.py @@ -184,6 +184,12 @@ class ProcessHandler(object): child.terminate(force=True) # add isalive check, to ensure exitstatus is set: child.isalive() + + # We follow the subprocess pattern, returning either the exit status + # as a positive number, or the terminating signal as a negative + # number + if child.signalstatus is not None: + return -child.signalstatus return child.exitstatus