tmux_identity (libtmux for Erlang v0.0.1)
View SourceObserve a Linux process incarnation using its PID, boot ID and start ticks.
1> Pid = list_to_integer(os:getpid()), ok.
ok
2> {ok, Identity} = tmux_identity:observe(Pid), ok.
ok
3> tmux_identity:check(Identity, Pid).
okA successful check is an observation. It neither reserves a PID nor pins a
tmux connection, and it never authorizes signalling a process. Endpoint owners
in tmux_server compare the PID returned by the current connection as well.
A server can still change between this check and a later one-shot command.
Use fingerprint/1 to compare captured incarnations across endpoint handles
or persist that comparison in a plan. It performs no process observation;
the key grants neither liveness nor permission to act.
Summary
Types
Versioned SHA-256 comparison key for a captured Linux process incarnation. The linux-v1 prefix identifies the canonical encoding, independent of Erlang term serialization. Keys compare identity observations, not endpoint ownership or current liveness. They are identifiers, not authentication tokens.
Observed Linux PID, boot identity and process-start token. It does not pin a connection.
Functions
Re-observe the PID and compare its incarnation token. A successful result is a momentary observation, not ownership, permission to signal, or a same-connection guarantee.
Derive a portable fingerprint/0 from a captured identity without I/O.
Observe a Linux PID incarnation without signalling it. Returns a tagged error if the process cannot be identified; this performs local operating-system I/O.
Types
-type fingerprint() :: binary().
Versioned SHA-256 comparison key for a captured Linux process incarnation. The linux-v1 prefix identifies the canonical encoding, independent of Erlang term serialization. Keys compare identity observations, not endpoint ownership or current liveness. They are identifiers, not authentication tokens.
-opaque t()
Observed Linux PID, boot identity and process-start token. It does not pin a connection.
Functions
-spec check(t(), pos_integer()) -> ok | {error, map()}.
Re-observe the PID and compare its incarnation token. A successful result is a momentary observation, not ownership, permission to signal, or a same-connection guarantee.
-spec fingerprint(t()) -> {ok, fingerprint()} | {error, #{code := invalid_identity}}.
Derive a portable fingerprint/0 from a captured identity without I/O.
The key includes PID, boot ID and process-start ticks. Reconnecting to the same
process preserves it; changing any component changes it. The encoding is
versioned for persisted plans. Use check/2 for a fresh process observation.
Malformed identity terms return invalid_identity before hashing.
1> {ok, I} = tmux_identity:observe(list_to_integer(os:getpid())), ok.
ok
2> {ok, Key} = tmux_identity:fingerprint(I), ok.
ok
3> byte_size(Key).
73
-spec observe(pos_integer()) -> {ok, t()} | {error, map()}.
Observe a Linux PID incarnation without signalling it. Returns a tagged error if the process cannot be identified; this performs local operating-system I/O.