diff options
| author | Gregory P. Smith <greg@krypto.org> | 2012-09-29 19:41:03 (GMT) |
|---|---|---|
| committer | Gregory P. Smith <greg@krypto.org> | 2012-09-29 19:41:03 (GMT) |
| commit | 0f21adf7999d0a50889cde65419e51cfe77e9e1d (patch) | |
| tree | 0d689e15c8fc5887b47f76bd13881a9cc23eb92c /Lib | |
| parent | b32d5912d2a6504740146e4d4b1a477189e932d2 (diff) | |
| download | cpython-0f21adf7999d0a50889cde65419e51cfe77e9e1d.zip cpython-0f21adf7999d0a50889cde65419e51cfe77e9e1d.tar.gz cpython-0f21adf7999d0a50889cde65419e51cfe77e9e1d.tar.bz2 | |
pty.spawn() now returns the child process status as returned by os.waitpid().
Addresses the remaining feature request from issue #2489.
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/pty.py | 1 | ||||
| -rw-r--r-- | Lib/test/test_pty.py | 6 |
2 files changed, 7 insertions, 0 deletions
@@ -178,3 +178,4 @@ def spawn(argv, master_read=_read, stdin_read=_read): tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode) os.close(master_fd) + return os.waitpid(pid, 0)[1] diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py index ef95268..db37039 100644 --- a/Lib/test/test_pty.py +++ b/Lib/test/test_pty.py @@ -196,6 +196,12 @@ class PtyTest(unittest.TestCase): # pty.fork() passed. + def test_spawn_returns_status(self): + status = pty.spawn([sys.executable, '-c', 'import sys; sys.exit(0)']) + self.assertEqual(status, 0) + status = pty.spawn([sys.executable, '-c', 'import sys; sys.exit(5)']) + self.assertEqual(status, 5 << 8) + class SmallPtyTests(unittest.TestCase): """These tests don't spawn children or hang.""" |
