Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Lib/test/regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,9 @@ def __exit__(self, exc_type, exc_val, exc_tb):
return False


def post_test_cleanup():
test_support.reap_children()

def runtest_inner(test, verbose, quiet, huntrleaks=False, pgo=False, testdir=None):
test_support.unload(test)
if verbose:
Expand Down Expand Up @@ -1205,6 +1208,7 @@ def runtest_inner(test, verbose, quiet, huntrleaks=False, pgo=False, testdir=Non
refleak = dash_R(the_module, test, indirect_test,
huntrleaks)
test_time = time.time() - start_time
post_test_cleanup()
finally:
sys.stdout = save_stdout
except test_support.ResourceDenied, msg:
Expand Down
7 changes: 7 additions & 0 deletions Lib/test/test_tempfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,15 @@ def test_process_awareness(self):
try:
pid = os.fork()
if not pid:
# child process
os.close(read_fd)
os.write(write_fd, next(self.r).encode("ascii"))
os.close(write_fd)
# bypass the normal exit handlers- leave those to
# the parent.
os._exit(0)

# parent process
parent_value = next(self.r)
child_value = os.read(read_fd, len(parent_value)).decode("ascii")
finally:
Expand All @@ -157,6 +160,10 @@ def test_process_awareness(self):
os.kill(pid, signal.SIGKILL)
except EnvironmentError:
pass

# Read the process exit status to avoid zombie process
os.waitpid(pid, 0)

os.close(read_fd)
os.close(write_fd)
self.assertNotEqual(child_value, parent_value)
Expand Down