(self)
| 496 | 'need os.waitpid() and os.WNOHANG') |
| 497 | @support.requires_fork() |
| 498 | def test_reap_children(self): |
| 499 | # Make sure that there is no other pending child process |
| 500 | support.reap_children() |
| 501 | |
| 502 | # Create a child process |
| 503 | pid = os.fork() |
| 504 | if pid == 0: |
| 505 | # child process: do nothing, just exit |
| 506 | os._exit(0) |
| 507 | |
| 508 | was_altered = support.environment_altered |
| 509 | try: |
| 510 | support.environment_altered = False |
| 511 | stderr = io.StringIO() |
| 512 | |
| 513 | for _ in support.sleeping_retry(support.SHORT_TIMEOUT): |
| 514 | with support.swap_attr(support.print_warning, 'orig_stderr', stderr): |
| 515 | support.reap_children() |
| 516 | |
| 517 | # Use environment_altered to check if reap_children() found |
| 518 | # the child process |
| 519 | if support.environment_altered: |
| 520 | break |
| 521 | |
| 522 | msg = "Warning -- reap_children() reaped child process %s" % pid |
| 523 | self.assertIn(msg, stderr.getvalue()) |
| 524 | self.assertTrue(support.environment_altered) |
| 525 | finally: |
| 526 | support.environment_altered = was_altered |
| 527 | |
| 528 | # Just in case, check again that there is no other |
| 529 | # pending child process |
| 530 | support.reap_children() |
| 531 | |
| 532 | @support.requires_subprocess() |
| 533 | def check_options(self, args, func, expected=None): |
nothing calls this directly
no test coverage detected