Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

target.ServerGeneration

Rust
  • Python Unavailable
  • Ruby Unavailable
  • Lua Unavailable
  • TypeScript Unavailable
  • Rust
  • Go Unavailable
  • Java Unavailable
  • .NET Unavailable
  • C++ Unavailable
  • Swift Unavailable

View as Markdown

Module
target
Package
libtmux
Source
crates/libtmux/src/target.rs
struct target.ServerGeneration
structoverload [source]
structoverload [source]
struct target.ServerGeneration

Which tmux daemon is answering on an endpoint.

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?;

2 declared, 0 inherited

Members

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

Type to search.