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

method libtmux

Server._socket_args

Return this server's -S/-L flags, measuring the socket path.

Source and package
Qualified name
libtmux.Server._socket_args
Module
libtmux
Declared in
Server
Package
libtmux
Source
src/libtmux/server.py
_socket_args (self) → list[str]

Description

Every path that spawns tmux for this server builds its argv from here, which is what makes the measurement total: a socket flag cannot reach tmux without having been measured on the way.

A tmux socket is a UNIX domain socket, so its path has to fit in SOCKET_PATH_MAX_BYTES. An explicit socket_path is settled the moment it is passed and is measured in __init__; measuring it again here is free and keeps this method total over every flag it renders.

A name or a bare server is different, and is measured only here, for the same reason colors is checked at this point: naming a server is not using one, so is_alive() has to stay answerable for a server that cannot be reached. It also reads TMUX_TMPDIR at the moment the tmux binary would read it, so an environment changed after construction is measured as tmux sees it rather than as it once was.

Returns

list[str] ["-S<path>"], ["-L<name>"], or [] for a bare server, which leaves tmux to pick the socket itself -- TMUX inside a pane, and a path under TMUX_TMPDIR outside one.

Raises
  • SocketPathTooLong – When the socket path -- given, or resolved from socket_name -- cannot fit in a UNIX socket address.

Examples

>>> server._socket_args()
['-Llibtmux_test...']
>>> from libtmux.server import Server as TmuxServer
>>> TmuxServer(socket_path="/tmp/short/sock")._socket_args()
['-S/tmp/short/sock']

A bare server names no socket, and tmux falls back to its own default:

>>> TmuxServer()._socket_args()
[]

A path too long to bind is refused here, before tmux is spawned:

>>> try:
... TmuxServer(socket_path="/tmp/" + "d" * 120 + "/sock")._socket_args()
... except exc.SocketPathTooLong as e:
... print(e.length)
130

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.Server._socket_args.

Esc
Search in

Type to search.

Reference previewOpen reference