Show More
@@ -2328,6 +2328,11 class InteractiveShell(SingletonConfigurable): | |||
|
2328 | 2328 | ec = subprocess.call(cmd, shell=True, executable=os.environ.get('SHELL', None)) |
|
2329 | 2329 | # exit code is positive for program failure, or negative for |
|
2330 | 2330 | # terminating signal number. |
|
2331 | ||
|
2332 | # Interpret ec > 128 as signal | |
|
2333 | # Some shells (csh, fish) don't follow sh/bash conventions for exit codes | |
|
2334 | if ec > 128: | |
|
2335 | ec = -(ec - 128) | |
|
2331 | 2336 | |
|
2332 | 2337 | # We explicitly do NOT return the subprocess status code, because |
|
2333 | 2338 | # a non-None value would trigger :func:`sys.displayhook` calls. |
@@ -25,9 +25,12 from os.path import join | |||
|
25 | 25 | import nose.tools as nt |
|
26 | 26 | |
|
27 | 27 | from IPython.core.inputtransformer import InputTransformer |
|
28 |
from IPython.testing.decorators import |
|
|
28 | from IPython.testing.decorators import ( | |
|
29 | skipif, skip_win32, onlyif_unicode_paths, onlyif_cmds_exist, | |
|
30 | ) | |
|
29 | 31 | from IPython.testing import tools as tt |
|
30 | 32 | from IPython.utils import io |
|
33 | from IPython.utils.process import find_cmd | |
|
31 | 34 | from IPython.utils import py3compat |
|
32 | 35 | from IPython.utils.py3compat import unicode_type, PY3 |
|
33 | 36 | |
@@ -436,7 +439,7 class ExitCodeChecks(tt.TempFileMixin): | |||
|
436 | 439 | def test_exit_code_error(self): |
|
437 | 440 | self.system('exit 1') |
|
438 | 441 | self.assertEqual(ip.user_ns['_exit_code'], 1) |
|
439 | ||
|
442 | ||
|
440 | 443 | @skipif(not hasattr(signal, 'SIGALRM')) |
|
441 | 444 | def test_exit_code_signal(self): |
|
442 | 445 | self.mktmp("import signal, time\n" |
@@ -444,6 +447,18 class ExitCodeChecks(tt.TempFileMixin): | |||
|
444 | 447 | "time.sleep(1)\n") |
|
445 | 448 | self.system("%s %s" % (sys.executable, self.fname)) |
|
446 | 449 | self.assertEqual(ip.user_ns['_exit_code'], -signal.SIGALRM) |
|
450 | ||
|
451 | @onlyif_cmds_exist("csh") | |
|
452 | def test_exit_code_signal_csh(self): | |
|
453 | SHELL = os.environ.get('SHELL', None) | |
|
454 | os.environ['SHELL'] = find_cmd("csh") | |
|
455 | try: | |
|
456 | self.test_exit_code_signal() | |
|
457 | finally: | |
|
458 | if SHELL is not None: | |
|
459 | os.environ['SHELL'] = SHELL | |
|
460 | else: | |
|
461 | del os.environ['SHELL'] | |
|
447 | 462 | |
|
448 | 463 | class TestSystemRaw(unittest.TestCase, ExitCodeChecks): |
|
449 | 464 | system = ip.system_raw |
General Comments 0
You need to be logged in to leave comments.
Login now