Free up memory used to store copy of child env block
This commit is contained in:
@@ -224,38 +224,36 @@ class Child:
|
|||||||
self.stdin = stdin
|
self.stdin = stdin
|
||||||
self.env = env or {}
|
self.env = env or {}
|
||||||
|
|
||||||
@property
|
|
||||||
def final_env(self) -> Dict[str, str]:
|
def final_env(self) -> Dict[str, str]:
|
||||||
from kitty.options.utils import DELETE_ENV_VAR
|
from kitty.options.utils import DELETE_ENV_VAR
|
||||||
env: Optional[Dict[str, str]] = getattr(self, '_final_env', None)
|
env = default_env().copy()
|
||||||
if env is None:
|
if is_macos and env.get('LC_CTYPE') == 'UTF-8' and not sys._xoptions.get(
|
||||||
env = self._final_env = default_env().copy()
|
'lc_ctype_before_python') and not getattr(default_env, 'lc_ctype_set_by_user', False):
|
||||||
if is_macos and env.get('LC_CTYPE') == 'UTF-8' and not sys._xoptions.get(
|
del env['LC_CTYPE']
|
||||||
'lc_ctype_before_python') and not getattr(default_env, 'lc_ctype_set_by_user', False):
|
env.update(self.env)
|
||||||
del env['LC_CTYPE']
|
env['TERM'] = fast_data_types.get_options().term
|
||||||
env.update(self.env)
|
env['COLORTERM'] = 'truecolor'
|
||||||
env['TERM'] = fast_data_types.get_options().term
|
env['KITTY_PID'] = getpid()
|
||||||
env['COLORTERM'] = 'truecolor'
|
if self.cwd:
|
||||||
env['KITTY_PID'] = getpid()
|
# needed in case cwd is a symlink, in which case shells
|
||||||
if self.cwd:
|
# can use it to display the current directory name rather
|
||||||
# needed in case cwd is a symlink, in which case shells
|
# than the resolved path
|
||||||
# can use it to display the current directory name rather
|
env['PWD'] = self.cwd
|
||||||
# than the resolved path
|
tdir = checked_terminfo_dir()
|
||||||
env['PWD'] = self.cwd
|
if tdir:
|
||||||
tdir = checked_terminfo_dir()
|
env['TERMINFO'] = tdir
|
||||||
if tdir:
|
env['KITTY_INSTALLATION_DIR'] = kitty_base_dir
|
||||||
env['TERMINFO'] = tdir
|
opts = fast_data_types.get_options()
|
||||||
env['KITTY_INSTALLATION_DIR'] = kitty_base_dir
|
self.unmodified_argv = list(self.argv)
|
||||||
opts = fast_data_types.get_options()
|
if 'disabled' not in opts.shell_integration:
|
||||||
self.unmodified_argv = list(self.argv)
|
from .shell_integration import modify_shell_environ
|
||||||
if 'disabled' not in opts.shell_integration:
|
modify_shell_environ(opts, env, self.argv)
|
||||||
from .shell_integration import modify_shell_environ
|
env = {k: v for k, v in env.items() if v is not DELETE_ENV_VAR}
|
||||||
modify_shell_environ(opts, env, self.argv)
|
if self.is_clone_launch:
|
||||||
env = {k: v for k, v in env.items() if v is not DELETE_ENV_VAR}
|
env['KITTY_IS_CLONE_LAUNCH'] = self.is_clone_launch
|
||||||
if self.is_clone_launch:
|
self.is_clone_launch = '1' # free memory
|
||||||
env['KITTY_IS_CLONE_LAUNCH'] = self.is_clone_launch
|
else:
|
||||||
else:
|
env.pop('KITTY_IS_CLONE_LAUNCH', None)
|
||||||
env.pop('KITTY_IS_CLONE_LAUNCH', None)
|
|
||||||
return env
|
return env
|
||||||
|
|
||||||
def fork(self) -> Optional[int]:
|
def fork(self) -> Optional[int]:
|
||||||
@@ -271,7 +269,7 @@ class Child:
|
|||||||
remove_cloexec(stdin_read_fd)
|
remove_cloexec(stdin_read_fd)
|
||||||
else:
|
else:
|
||||||
stdin_read_fd = stdin_write_fd = -1
|
stdin_read_fd = stdin_write_fd = -1
|
||||||
env = tuple(f'{k}={v}' for k, v in self.final_env.items())
|
env = tuple(f'{k}={v}' for k, v in self.final_env().items())
|
||||||
argv = list(self.argv)
|
argv = list(self.argv)
|
||||||
exe = argv[0]
|
exe = argv[0]
|
||||||
if is_macos and exe == shell_path:
|
if is_macos and exe == shell_path:
|
||||||
|
|||||||
@@ -881,7 +881,7 @@ class Window:
|
|||||||
if cb and cb != ['none']:
|
if cb and cb != ['none']:
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
env = self.child.final_env
|
env = self.child.foreground_environ
|
||||||
env['KITTY_CHILD_CMDLINE'] = ' '.join(map(shlex.quote, self.child.cmdline))
|
env['KITTY_CHILD_CMDLINE'] = ' '.join(map(shlex.quote, self.child.cmdline))
|
||||||
subprocess.Popen(cb, env=env, cwd=self.child.foreground_cwd)
|
subprocess.Popen(cb, env=env, cwd=self.child.foreground_cwd)
|
||||||
if not self.is_active:
|
if not self.is_active:
|
||||||
|
|||||||
Reference in New Issue
Block a user