On this page
server.Server.from_env
- Module
- server
- Declared in
- Server
- Package
- libtmux
- Source
- crates/libtmux/src/server.rs
-
Build a server from the
TMUXvariable tmux exports into every pane.tmux sets
TMUXto `<socket_path>,<server_pid>,<session_id>`. Only the socket path is used: the pid and session id are frozen when the pane spawns, and the session id goes stale as soon as the pane's window is moved to another session.Being frozen is what makes the pid worth something to a caller who wants to know the daemon has not been replaced since. A server that restarts on the same socket answers here just as well, and reissues ids from the start, so
Server::generationandServer::require_generationare what tell the two apart. This does not check on its own initiative, because that would cost a round trip on a call documented as running no tmux command.This runs no tmux command and does not check that the server is alive; use
Server::is_alivefor that.Errors
Returns an error when
TMUXis unset, empty, or not shaped like that triple, and when the socket path it names is unusable.Examples
let outside = libtmux::Server::from_env_value(None::<OsString>); assert!(outside.is_err(), "a process outside tmux has no TMUX value"); let inside = libtmux::Server::from_env_value(Some("/tmp/tmux-1000/default,7,$0"))?; assert_eq!(inside.socket_path(), std::path::Path::new("/tmp/tmux-1000/default"));Discussed in Environment
0 declared, 0 inherited