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.

typealias libtmux-ts latest

DaemonGuard

Making a command refuse to run on a daemon that is not the one it was read from.

Source and package
Qualified name
DaemonGuard
Module
engine
Package
libtmux
Source
packages/libtmux/src/engine.ts
type engine.DaemonGuard = { readonly pid: string; readonly startTime: string; }

Description#

A tmux id is unique within one daemon and reissued by the next: kill-server and a restart give a new daemon the same socket, and it numbers its panes from %0 again. A handle captured before the restart therefore names something that exists, belongs to somebody else, and answers to the same command.

Checking first and sending second does not close that: the daemon can change between the two. if-shell -F does, because it is not a shell — tmux expands the format inside its command queue and cmdq_insert_afters the guarded command into the same queue, so nothing runs in between. The condition is pid and start_time together, since pids are reused.

The refusal has to be visible. tmux answers a false condition with no output and status 0, which is indistinguishable from a command that printed nothing, so the else branch is a freshly named unknown command. A 128-bit suffix makes matching a pre-existing command alias a guess, and the exact diagnostic distinguishes the refusal from the guarded command failing. The guarded command keeps its own stdout and stderr either way.

Esc

Type to search.

Reference previewOpen reference