Commit 79f561d1 authored by Martin Panter's avatar Martin Panter

Issue #26870: Poll() also fails on OS X; try select()

Also work around separate Open BSD bug with kill() of a zombie.
parent 2e1d8683
...@@ -126,13 +126,20 @@ def run_pty(script, input=b"dummy input\r"): ...@@ -126,13 +126,20 @@ def run_pty(script, input=b"dummy input\r"):
os.close(slave) os.close(slave)
with ExitStack() as cleanup: with ExitStack() as cleanup:
cleanup.enter_context(proc) cleanup.enter_context(proc)
cleanup.callback(proc.terminate) def terminate(proc):
try:
proc.terminate()
except ProcessLookupError:
# Workaround for Open/Net BSD bug (Issue 16762)
pass
cleanup.callback(terminate, proc)
cleanup.callback(os.close, master) cleanup.callback(os.close, master)
# Avoid using DefaultSelector, because it may choose a kqueue() # Avoid using DefaultSelector and PollSelector. Kqueue() does not
# implementation, which does not work with pseudo-terminals on OS X # work with pseudo-terminals on OS X < 10.9 (Issue 20365) and Open
# < 10.9 (Issue 20365) and Open BSD (Issue 20667). # BSD (Issue 20667). Poll() does not work with OS X 10.6 or 10.4
sel = getattr(selectors, "PollSelector", selectors.DefaultSelector)() # either (Issue 20472). Hopefully the file descriptor is low enough
cleanup.enter_context(sel) # to use with select().
sel = cleanup.enter_context(selectors.SelectSelector())
sel.register(master, selectors.EVENT_READ | selectors.EVENT_WRITE) sel.register(master, selectors.EVENT_READ | selectors.EVENT_WRITE)
os.set_blocking(master, False) os.set_blocking(master, False)
while True: while True:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment