From c08fb91b2991da79045b7df70cb4c5d3e6909fac Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 7 Oct 2024 21:13:54 +0530 Subject: [PATCH] Add comments document realpath behavior for cwd_of_process --- kitty/child.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kitty/child.py b/kitty/child.py index c87bda2ed..65a7519b4 100644 --- a/kitty/child.py +++ b/kitty/child.py @@ -30,6 +30,8 @@ if is_macos: from kitty.fast_data_types import process_group_map as _process_group_map def cwd_of_process(pid: int) -> str: + # The underlying code on macos returns a path with symlinks resolved + # anyway but we use realpath for extra safety. return os.path.realpath(_cwd(pid)) def process_group_map() -> DefaultDict[int, list[int]]: @@ -56,6 +58,8 @@ else: return os.path.realpath(ans) else: def cwd_of_process(pid: int) -> str: + # We use realpath instead of readlink to match macOS behavior where + # the underlying OS API returns real paths. ans = f'/proc/{pid}/cwd' return os.path.realpath(ans)