(root)/
Python-3.11.7/
Lib/
test/
subprocessdata/
sigchild_ignore.py
       1  import signal, subprocess, sys, time
       2  # On Linux this causes os.waitpid to fail with OSError as the OS has already
       3  # reaped our child process.  The wait() passing the OSError on to the caller
       4  # and causing us to exit with an error is what we are testing against.
       5  signal.signal(signal.SIGCHLD, signal.SIG_IGN)
       6  subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
       7  # Also ensure poll() handles an errno.ECHILD appropriately.
       8  p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
       9  num_polls = 0
      10  while p.poll() is None:
      11      # Waiting for the process to finish.
      12      time.sleep(0.01)  # Avoid being a CPU busy loop.
      13      num_polls += 1
      14      if num_polls > 3000:
      15          raise RuntimeError('poll should have returned 0 within 30 seconds')