Report the correct cmdline for prewarmed processes

This commit is contained in:
Kovid Goyal 2022-06-08 13:54:30 +05:30
parent 0ed7b2f3c0
commit 6807f4d4ea
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 2 deletions

View File

@ -339,7 +339,7 @@ class Child:
ans = cmdline_of_pid(pid)
except Exception:
ans = []
if not ans and pid == self.pid:
if pid == self.pid and (not ans or (self.is_prewarmed and fast_data_types.get_boss().prewarm.is_prewarmed_argv(ans))):
ans = list(self.argv)
return ans

View File

@ -12,7 +12,8 @@ from contextlib import suppress
from dataclasses import dataclass
from importlib import import_module
from typing import (
IO, TYPE_CHECKING, Any, Dict, List, NoReturn, Optional, Union, cast
IO, TYPE_CHECKING, Any, Dict, List, NoReturn, Optional, Sequence, Union,
cast
)
from kitty.constants import kitty_exe
@ -79,6 +80,11 @@ class PrewarmProcess:
opts = get_options()
return json.dumps({'paths': opts.config_paths, 'overrides': opts.config_overrides})
def is_prewarmed_argv(self, argv: Sequence[str]) -> bool:
if argv[:2] != [kitty_exe(), '+runpy']:
return False
return len(argv) > 2 and argv[2].startswith('from kitty.prewarm import main; main(')
def ensure_worker(self) -> None:
if not self.worker_started:
import subprocess