From e615009378a7fd9c257cb3ce6614f52887c5ef27 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 23 Oct 2026 01:19:40 +0530 Subject: [PATCH] Use the root process for the window pid in ls and pid matching This makes the pid consistent with the cmdline, cwd and env reported for the window, which already skip over wrappers kitty inserts such as /usr/bin/login on macOS and the wrapper used for --hold. --- docs/changelog.rst | 8 +++++--- kitty/window.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 69f9310f2..c0c1db85f 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -237,10 +237,12 @@ Detailed list of changes :file:`/usr/bin/login` on macOS, are now skipped, so their first child is used as the root process -- macOS: The working directory, command line and environment of a window +- The pid, working directory, command line and environment of a window reported by :ref:`kitten @ ls ` and used when matching windows by - :code:`cwd`, :code:`cmdline` or :code:`env` are now those of the shell rather - than of the :file:`/usr/bin/login` wrapper kitty runs it with + :code:`pid`, :code:`cwd`, :code:`cmdline` or :code:`env` are now those of the + process kitty was asked to run rather than of a wrapper kitty runs it with, + such as :file:`/usr/bin/login` on macOS or the wrapper used for + :option:`launch --hold` - Remote control: Fix a crash when using damaged images with :code:`set-window-logo` or :code:`set-background-image` (:pull:`10715`) diff --git a/kitty/window.py b/kitty/window.py index 8ebf8bcd9..9edc5d9d5 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -968,7 +968,7 @@ class Window: if field in ('id', 'window_id'): return pat.pattern == str(self.id) if field == 'pid': - return pat.pattern == str(self.child.pid) + return pat.pattern == str(self.child.root_pid) if field == 'title': return pat.search(self.override_title or self.title) is not None if field in 'cwd': @@ -2425,7 +2425,7 @@ class Window: 'is_active': is_active, 'title': self.title, 'title_overridden': self.override_title is not None, - 'pid': self.child.pid, + 'pid': self.child.root_pid, 'cwd': self.child.current_cwd or self.child.cwd, 'cmdline': self.child.cmdline, 'last_reported_cmdline': self.last_cmd_cmdline,