on linux this causes os waitpid to fail with oserror as the os has already reaped our child process the wait passing the oserror on to the caller and causing us to exit with an error is what we are testing against also ensure poll handles an errno echild appropriately waiting for the process to finish on linux this causes os waitpid to fail with oserror as the os has already reaped our child process the wait passing the oserror on to the caller and causing us to exit with an error is what we are testing against also ensure poll handles an errno echild appropriately waiting for the process to finish avoid being a cpu busy loop
import signal, subprocess, sys, time



signal.signal(signal.SIGCHLD, signal.SIG_IGN)
subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()

p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
num_polls = 0
while p.poll() is None:
    
    time.sleep(0.01)  
    num_polls += 1
    if num_polls > 3000:
        raise RuntimeError('poll should have returned 0 within 30 seconds')