mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 17:52:02 +02:00
Dont hang trying to read shell environment if the shell never quits. Fixes #2143
This commit is contained in:
@@ -214,7 +214,9 @@ def read_shell_environment(opts=None):
|
|||||||
with os.fdopen(master, 'rb') as stdout, os.fdopen(slave, 'wb'):
|
with os.fdopen(master, 'rb') as stdout, os.fdopen(slave, 'wb'):
|
||||||
raw = b''
|
raw = b''
|
||||||
from subprocess import TimeoutExpired
|
from subprocess import TimeoutExpired
|
||||||
while True:
|
from time import monotonic
|
||||||
|
start_time = monotonic()
|
||||||
|
while monotonic() - start_time < 1.5:
|
||||||
try:
|
try:
|
||||||
ret = p.wait(0.01)
|
ret = p.wait(0.01)
|
||||||
except TimeoutExpired:
|
except TimeoutExpired:
|
||||||
@@ -223,7 +225,10 @@ def read_shell_environment(opts=None):
|
|||||||
raw += stdout.read()
|
raw += stdout.read()
|
||||||
if ret is not None:
|
if ret is not None:
|
||||||
break
|
break
|
||||||
if p.returncode == 0:
|
if p.returncode is None:
|
||||||
|
log_error('Timed out waiting for shell to quit while reading shell environment')
|
||||||
|
p.kill()
|
||||||
|
elif p.returncode == 0:
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
x = stdout.read()
|
x = stdout.read()
|
||||||
|
|||||||
Reference in New Issue
Block a user