`Server.kill_session(name)` kills a session whose name only starts with `name`

Open Beginner friendly
#839 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
83/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Read src/libtmux/server.py around Server.kill_session (lines 483–500) and compare its target handling with has_session(exact=True) around line 429. Then find the relevant kill-session tests and run them. Done means killing a nonexistent exact name raises while a session whose name only shares that prefix remains.

Written by the indexing model from the issue text.

Description

bug
Summary

Server.kill_session("doom") removes a session named doomsday when no doom exists. It passes the bare name to kill-session -t, and tmux resolves a bare target by prefix and fnmatch(3). The docstring says so ("'asdf' will kill 'asdfasd'"), while Server.has_session() already defaults to exact=True. Scripts that kill by name can end someone else's session.

Reproduction
  1. Create two sessions and kill by the shorter name:
import libtmux
srv = libtmux.Server(socket_name="kill-prefix", config_file="/dev/null")
srv.new_session("probe", window_command="sh")
srv.new_session("doomsday", window_command="sh")
srv.kill_session("doom")
print(sorted(s.name for s in srv.sessions))
srv.kill()
Expected

kill_session("doom") raises because no session named doom exists, and doomsday survives.

Actual

It returns normally and doomsday is gone: ['probe'].

Environment
  • libtmux: master at 886b1cd (v0.62.0 plus 114 commits)
  • tmux: 3.8 (system build reports 3.8a)
  • Python: run with uv run --frozen from the libtmux checkout
  • OS: Linux (WSL2), private -L socket, -f /dev/null
References
Dominant language
Python
Stars
1.2k
Forks
127
Avg merge
2h 37m
Merged PRs (30d)
33

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tmux-python/libtmux

All issues in tmux-python/libtmux

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.