Core Library0.xAPI reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

MoreLess about this notice

function libtmux

resolve_socket_path

Resolve the socket path tmux uses for socket_name.

Source and package
Qualified name
libtmux._internal.env.resolve_socket_path
Module
libtmux._internal.env
Package
libtmux
Source
src/libtmux/_internal/env.py
resolve_socket_path ( socket_name: str | None = None, env: t.Mapping[str, str] | None = None, ) → pathlib.Path

Description

tmux keeps its sockets in tmux-<euid> under TMUX_TMPDIR, falling back to /tmp when that is unset or empty. TMPDIR is deliberately not consulted -- tmux does not consult it either. The socket directory is resolved through symlinks, as tmux resolves it before binding, so a symlinked TMUX_TMPDIR yields the path tmux itself reports.

A TMUX_TMPDIR tmux cannot resolve falls back the same way. tmux takes the first of TMUX_TMPDIR and /tmp that resolves, so a path that is not there -- or a broken symlink -- is never the one it binds, and measuring it would refuse a server tmux reaches without difficulty. A directory it resolves but cannot create tmux-<euid> under is an error from tmux, not a fallback.

The path is computed, not observed: it says where tmux would put the socket, not that a daemon is listening there. Code holding a live Server should ask tmux instead, with the #{socket_path} format.

Parameters
Returns

pathlib.Path Path tmux resolves the socket to.

Examples

>>> from libtmux._internal.env import resolve_socket_path
>>> resolve_socket_path(env={})
PosixPath('/tmp/tmux-.../default')
>>> resolve_socket_path("mysocket", env={"TMUX_TMPDIR": "/usr"})
PosixPath('/usr/tmux-.../mysocket')

TMPDIR is not a socket directory, so it changes nothing:

>>> resolve_socket_path(env={"TMPDIR": "/var/folders/xy"})
PosixPath('/tmp/tmux-.../default')

Nor does a TMUX_TMPDIR tmux cannot use, however long it is:

>>> resolve_socket_path(env={"TMUX_TMPDIR": "/nonexistent-" + "d" * 200})
PosixPath('/tmp/tmux-.../default')

Recorded calls

source calls
No call edges in the Python model.

The Python reference records declarations, not calls, so this page shows no callers or callees. That is a limit of the extracted data, not a statement that nothing calls libtmux._internal.env.resolve_socket_path.

Esc
Search in

Type to search.

Reference previewOpen reference