Server.withControlMode(attachingTo:_:)
Opens a control-mode connection for the duration of body, handing over the connection itself.
Source and package
- Qualified name
-
Server.with Control Mode(attaching To: _:) - Declared in
Server- Package
- libtmux-swift
- Source
- Sources/LibTmux/ControlMode.swift
- withControlMode( attaching
To : String, body: @escaping (ControlSession ) async throws -> Result ) -> Result -
Description#
connected(attachingTo:_:)is the one to reach for: it gives the same connection and a server that speaks over it. This is the layer beneath, for talking the control protocol directly.The process is scoped even though Swift can retain the actor handed to
body. Returning or storing it does not extend the process lifetime; later calls fail. Whenbodyreturns, the session is closed and the child is reaped before this call does.Connection loss cancels
body; teardown still waits for code that ignores cancellation.- Parameters:
- session: the session to attach to. Control mode reports
%outputonly for a session it is attached to, so a connection with no target sees command replies and little else. - body: the work to run against the connection.
- session: the session to attach to. Control mode reports
- Throws:
TmuxError.connectionClosedif the connection ends beforebody, including whenbodydetaches its own client.
- Parameters:
tmux command#
The tmux commands behind withControlMode(attachingTo:_:).
tmux C API#
The C declarations in tmux that implement these commands.