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.

struct libtmux-rs latest

ServerGeneration

Which tmux daemon is answering on an endpoint.

Source and package
Qualified name
libtmux::target::ServerGeneration
Module
target
Package
libtmux
Source
crates/libtmux/src/target.rs
struct target.ServerGeneration

Description#

ServerIdentity answers "where", and that is not enough to answer "which": tmux reuses the socket file across restarts, so a replacement daemon is indistinguishable from the one it replaced by path alone. It also reissues ids from the start, so the replacement's first pane is %0 too.

Holding a handle across a possible restart is therefore a correctness question rather than a liveness one. A stale read fails harmlessly; a stale mutation lands on whatever now wears that id.

The pid alone would not do. A replacement daemon can be handed the pid of the one it replaced, so the start time is what makes this a generation rather than a guess.

Examples#

let guard = libtmux::test::TestServer::new().await?;
let server = guard.server();
// Capture the generation beside whatever ids are being held.
let generation = server.generation().await?;
let session = server.new_session("work").await?;
// Before acting on those ids later, confirm the daemon has not been
// replaced underneath them.
assert_eq!(server.generation().await?, generation);
let _ = session;
guard.shutdown().await?;

Members2#

  • pid method The tmux server process id.
  • start_time method When that server started, to the whole second tmux keeps.
Esc

Type to search.

Reference previewOpen reference