Manage fd lifecycles a bit better

This commit is contained in:
Kovid Goyal
2022-06-08 13:26:27 +05:30
parent 116128ebb5
commit 0ed7b2f3c0
2 changed files with 15 additions and 14 deletions

View File

@@ -821,13 +821,13 @@ def which(name: str, only_system: bool = False) -> Optional[str]:
def read_shell_environment(opts: Optional[Options] = None) -> Dict[str, str]:
ans: Optional[Dict[str, str]] = getattr(read_shell_environment, 'ans', None)
if ans is None:
from .child import openpty, remove_blocking
from .child import openpty
ans = {}
setattr(read_shell_environment, 'ans', ans)
import subprocess
shell = resolved_shell(opts)
master, slave = openpty()
remove_blocking(master)
os.set_blocking(master, False)
if '-l' not in shell and '--login' not in shell:
shell += ['-l']
if '-i' not in shell and '--interactive' not in shell: