mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-20 11:07:38 +03:00
Set the KITTY_PID env var when running child processes
This commit is contained in:
parent
94575a5cf6
commit
9e2590eb15
@ -78,6 +78,13 @@ Variables that kitty sets when running child programs
|
||||
Can be used with the :doc:`kitty remote control facility <remote-control>`.
|
||||
|
||||
|
||||
.. envvar:: KITTY_PID
|
||||
|
||||
An integer that is the process id for the kitty process in which the program
|
||||
is running. Allows programs to tell kitty to reload its config by sending it
|
||||
the SIGUSR1 signal.
|
||||
|
||||
|
||||
.. envvar:: WINDOWID
|
||||
|
||||
The id for the :term:`OS Window <os_window>` the program is running in. Only available
|
||||
|
@ -14,6 +14,7 @@
|
||||
import kitty.fast_data_types as fast_data_types
|
||||
|
||||
from .constants import is_macos, shell_path, terminfo_dir
|
||||
from .types import run_once
|
||||
|
||||
try:
|
||||
from typing import TypedDict
|
||||
@ -23,8 +24,9 @@
|
||||
|
||||
if is_macos:
|
||||
from kitty.fast_data_types import (
|
||||
cmdline_of_process, cwd_of_process as _cwd, environ_of_process as _environ_of_process,
|
||||
process_group_map as _process_group_map
|
||||
cmdline_of_process, cwd_of_process as _cwd,
|
||||
environ_of_process as _environ_of_process,
|
||||
process_group_map as _process_group_map
|
||||
)
|
||||
|
||||
def cwd_of_process(pid: int) -> str:
|
||||
@ -170,6 +172,11 @@ def openpty() -> Tuple[int, int]:
|
||||
return master, slave
|
||||
|
||||
|
||||
@run_once
|
||||
def getpid() -> str:
|
||||
return str(os.getpid())
|
||||
|
||||
|
||||
class ProcessDesc(TypedDict):
|
||||
cwd: Optional[str]
|
||||
pid: int
|
||||
@ -216,6 +223,7 @@ def final_env(self) -> Dict[str, str]:
|
||||
env.update(self.env)
|
||||
env['TERM'] = fast_data_types.get_options().term
|
||||
env['COLORTERM'] = 'truecolor'
|
||||
env['KITTY_PID'] = getpid()
|
||||
if self.cwd:
|
||||
# needed in case cwd is a symlink, in which case shells
|
||||
# can use it to display the current directory name rather
|
||||
|
Loading…
Reference in New Issue
Block a user