]> granicus.if.org Git - python/commitdiff
bpo-31160: Fix test_builtin for zombie process (#3043)
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 9 Aug 2017 15:44:19 +0000 (17:44 +0200)
committerGitHub <noreply@github.com>
Wed, 9 Aug 2017 15:44:19 +0000 (17:44 +0200)
PtyTests.run_child() now calls os.waitpid() to read the exit status
of the child process to avoid creating zombie process and leaking
processes in the background.

Lib/test/test_builtin.py

index a83d20f434394c8f76cc45303fbbbccf4aa79768..219a08abd3ffd8cada06a10ed153a5a9f5ab6df4 100644 (file)
@@ -1568,6 +1568,10 @@ class PtyTests(unittest.TestCase):
             self.fail("got %d lines in pipe but expected 2, child output was:\n%s"
                       % (len(lines), child_output))
         os.close(fd)
+
+        pid, status = os.waitpid(pid, 0)
+        self.assertEqual(status, 0)
+
         return lines
 
     def check_input_tty(self, prompt, terminal_input, stdio_encoding=None):