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