##// END OF EJS Templates
Merge pull request #6006 from minrk/ec128...
Thomas Kluyver -
r17017:fe42cfa8 merge
parent child Browse files
Show More
@@ -2328,6 +2328,11 b' class InteractiveShell(SingletonConfigurable):'
2328 ec = subprocess.call(cmd, shell=True, executable=os.environ.get('SHELL', None))
2328 ec = subprocess.call(cmd, shell=True, executable=os.environ.get('SHELL', None))
2329 # exit code is positive for program failure, or negative for
2329 # exit code is positive for program failure, or negative for
2330 # terminating signal number.
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 # We explicitly do NOT return the subprocess status code, because
2337 # We explicitly do NOT return the subprocess status code, because
2333 # a non-None value would trigger :func:`sys.displayhook` calls.
2338 # a non-None value would trigger :func:`sys.displayhook` calls.
@@ -25,9 +25,12 b' from os.path import join'
25 import nose.tools as nt
25 import nose.tools as nt
26
26
27 from IPython.core.inputtransformer import InputTransformer
27 from IPython.core.inputtransformer import InputTransformer
28 from IPython.testing.decorators import skipif, skip_win32, onlyif_unicode_paths
28 from IPython.testing.decorators import (
29 skipif, skip_win32, onlyif_unicode_paths, onlyif_cmds_exist,
30 )
29 from IPython.testing import tools as tt
31 from IPython.testing import tools as tt
30 from IPython.utils import io
32 from IPython.utils import io
33 from IPython.utils.process import find_cmd
31 from IPython.utils import py3compat
34 from IPython.utils import py3compat
32 from IPython.utils.py3compat import unicode_type, PY3
35 from IPython.utils.py3compat import unicode_type, PY3
33
36
@@ -436,7 +439,7 b' class ExitCodeChecks(tt.TempFileMixin):'
436 def test_exit_code_error(self):
439 def test_exit_code_error(self):
437 self.system('exit 1')
440 self.system('exit 1')
438 self.assertEqual(ip.user_ns['_exit_code'], 1)
441 self.assertEqual(ip.user_ns['_exit_code'], 1)
439
442
440 @skipif(not hasattr(signal, 'SIGALRM'))
443 @skipif(not hasattr(signal, 'SIGALRM'))
441 def test_exit_code_signal(self):
444 def test_exit_code_signal(self):
442 self.mktmp("import signal, time\n"
445 self.mktmp("import signal, time\n"
@@ -444,6 +447,18 b' class ExitCodeChecks(tt.TempFileMixin):'
444 "time.sleep(1)\n")
447 "time.sleep(1)\n")
445 self.system("%s %s" % (sys.executable, self.fname))
448 self.system("%s %s" % (sys.executable, self.fname))
446 self.assertEqual(ip.user_ns['_exit_code'], -signal.SIGALRM)
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 class TestSystemRaw(unittest.TestCase, ExitCodeChecks):
463 class TestSystemRaw(unittest.TestCase, ExitCodeChecks):
449 system = ip.system_raw
464 system = ip.system_raw
General Comments 0
You need to be logged in to leave comments. Login now