On this page
engine.DaemonGuard
- Module
- engine
- Package
- @libtmux/libtmux
- Source
- packages/libtmux/src/engine.ts
-
Making a command refuse to run on a daemon that is not the one it was read from.
A tmux id is unique within one daemon and reissued by the next:
kill-serverand a restart give a new daemon the same socket, and it numbers its panes from%0again. 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 -Fdoes, because it is not a shell — tmux expands the format inside its command queue andcmdq_insert_afters the guarded command into the same queue, so nothing runs in between. The condition ispidandstart_timetogether, 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.
0 declared, 0 inherited