Commit graph

18 commits

Author SHA1 Message Date
Kovid Goyal
0b56ffd328
panel kitten: Use the invocation cwd and a cleaned env for single instance commands
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
A new panel created via single instance now runs in the working
directory of the invocation, rather than that of the first instance, as
commands run in existing panels and other single instance commands
already do. The environment of the invocation is cleaned up with
process_env() as for other single instance commands, so that variables
such as XDG_ACTIVATION_TOKEN and VTE_VERSION are not passed to the
commands.
2026-11-19 19:56:17 +05:30
Kovid Goyal
d5be3448a6
Use the launch wrapper for commands run via a single instance panel
Commands sent to an already running panel or quick access terminal, both
in existing panels and in newly created ones, are now user launches
passed to the launch wrapper. They have no source window, since they are
not run from any window in the panel. A new panel without a command runs
the shell instead of the run-shell kitten, so the wrapper sees the actual
shell, as for a panel started without single instance.

Closes #10900
2026-11-19 19:53:02 +05:30
Zhizhen He
c5d941b6c0 Fix default Bash detection in launch wrappers 2026-11-19 16:53:30 +08:00
Kovid Goyal
c83027daa9
Fix test_launch_wrapper_invalid_shell on macOS
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
On macOS the default shell is run via /usr/bin/login and the run-shell
kitten, with the user wrapper placed inside login, so the expected argv
differs from Linux.
2026-11-18 20:44:44 +05:30
Kovid Goyal
e87f68becd
skip test under qemu emulation 2026-11-18 20:17:58 +05:30
Kovid Goyal
2e62f9c96b
fix flaky test 2026-11-18 19:48:52 +05:30
Kovid Goyal
5b33eff326
Cleanup previous PR 2026-11-18 17:11:36 +05:30
Zhizhen He
c805a6e2a4 Fall back when launch wrapper context setup fails
Building LaunchContext resolves the configured shell. Catch that failure at the launch wrapper boundary so an explicit command can still start.
2026-11-18 19:14:42 +08:00
Zhizhen He
fea2fff082 Avoid caching helper PIDs for launch wrappers
A user launch wrapper can start a persistent helper before the command. Use a lone, unmatched child for the current lookup and cache the child only once its command line matches the launch arguments.
2026-11-18 12:04:49 +08:00
Kovid Goyal
8133effda3
Cleanup previous PR
A wrapper that runs the command as a child, rather than exec-ing it, can
run other children before, after or alongside it, such as a script that
runs some setup commands first. Re-check that the cached child of a
wrapper is still its live child, so that root_pid does not get stuck on
an exited helper, or on the command after it exits while the wrapper
keeps running. When a wrapper has several children, prefer the one
running the wrapped command, and only cache the choice if it is certain.

Match wrappers specified by name when their argv[0] is the path they
were found at, as is the case when run by the hold kitten, and wrappers
specified by path only by that exact path.

Compare the wrapper argv and the script arguments with empty arguments
dropped, as cmdline_of_pid() does on Linux, in one place, so that
binary wrappers with empty arguments are also matched.

Add tests for wrappers that run other commands, that exec after being
seen, with prefix and empty arguments, run via the hold kitten, and for
matches_cmdline() and runs_command().
2026-11-18 08:21:55 +05:30
Zhizhen He
8fe8b2bfeb
Fix root PID tracking for script launch wrappers
Recognize the original script invocation after the interpreter arguments so root_pid can follow wrappers that run the command as a child.
2026-11-18 07:50:46 +05:30
Kovid Goyal
f8556bbf8d
Fix #10858 2026-11-14 08:16:53 +05:30
Kovid Goyal
6815b7a8a4
More useful error message for flaky test failure 2026-10-26 06:50:34 +05:30
Kovid Goyal
4a99b367c5
Use the root process, not kitty's wrapper, for a window's process info
The cmdline, environment and working directory of a window, as reported
by kitten @ ls, used for matching windows and saved in the window state,
now come from the root process, skipping over wrappers kitty inserts
such as /usr/bin/login on macOS. Previously on macOS these described the
login process. Cache the resolved root process so that this is cheap.
2026-10-23 01:17:33 +05:30
Kovid Goyal
b6df55d1c6
Fix process tree memory accounting missing children of non-main threads
On Linux /proc/<pid>/task/<pid>/children only lists the children
created by the main thread, so children created by other threads of
multi-threaded programs were missed. Read the children lists of all
threads instead. On kernels without per thread children lists, build
the full parent to children map once instead of finding nothing. Also
avoid computing the descendants twice when the cgroup contains
processes outside the tree.
2026-10-23 01:13:42 +05:30
Kovid Goyal
42f241da28
Fix launch --cwd=root using the wrong process
When the root process was not in the foreground, cwd=root used the cwd
of the foreground process instead of the root process. Also skip over
wrapper processes that kitty itself inserts, such as /usr/bin/login on
macOS and the run-shell kitten used for --hold, using their first child
as the root process instead. Previously on macOS cwd=root always
resolved to the home directory, the cwd of login.

On Linux, read the children of all threads of a process, since
multi-threaded programs such as kitten can create children from any
thread.

Make cwd_of_child and modify_argv_for_launch_with_cwd use the same
logic for deciding when the reported cwd applies to cwd=root.

Closes #10720
2026-10-23 01:07:04 +05:30
Kovid Goyal
9d33c21131
... 2026-08-05 05:32:57 +05:30
Kovid Goyal
5cd6072570
Function to get memory used by processes rooted at pid 2026-07-29 13:25:51 +05:30