mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-11-13 12:09:35 +03:00
macOS has no waitid
Le Sigh
This commit is contained in:
parent
163c211219
commit
7113580db2
@ -45,18 +45,32 @@ class Child:
|
||||
child_process_pid: int
|
||||
|
||||
|
||||
def wait_for_child_death(child_pid: int, timeout: float = 1) -> Optional[int]:
|
||||
st = time.monotonic()
|
||||
while time.monotonic() - st < timeout:
|
||||
try:
|
||||
x = os.waitid(os.P_PID, child_pid, os.WEXITED | os.WNOHANG)
|
||||
except ChildProcessError:
|
||||
return 0
|
||||
else:
|
||||
if x is not None and x.si_pid == child_pid:
|
||||
return x.si_status
|
||||
time.sleep(0.01)
|
||||
return None
|
||||
if hasattr(os, 'waitid'):
|
||||
def wait_for_child_death(child_pid: int, timeout: float = 1) -> Optional[int]:
|
||||
st = time.monotonic()
|
||||
while time.monotonic() - st < timeout:
|
||||
try:
|
||||
x = os.waitid(os.P_PID, child_pid, os.WEXITED | os.WNOHANG)
|
||||
except ChildProcessError:
|
||||
return 0
|
||||
else:
|
||||
if x is not None and x.si_pid == child_pid:
|
||||
return x.si_status
|
||||
time.sleep(0.01)
|
||||
return None
|
||||
else:
|
||||
def wait_for_child_death(child_pid: int, timeout: float = 1) -> Optional[int]:
|
||||
st = time.monotonic()
|
||||
while time.monotonic() - st < timeout:
|
||||
try:
|
||||
pid, status = os.waitpid(child_pid, os.WNOHANG)
|
||||
except ChildProcessError:
|
||||
return 0
|
||||
else:
|
||||
if pid == child_pid:
|
||||
return status
|
||||
time.sleep(0.01)
|
||||
return None
|
||||
|
||||
|
||||
class PrewarmProcess:
|
||||
|
Loading…
Reference in New Issue
Block a user