libtmux Reference MCP Search
On this page

Server.withControlMode(attachingTo:_:)

View as Markdown

Declared in
Server
Package
libtmux-swift
Source
Sources/LibTmux/ControlMode.swift
withControlMode(attachingTo:_:) ( attachingTo : String , body : @escaping (ControlSession) async throws -> Result ) Result
methodasync [source]
methodasync [source]
withControlMode(attachingTo:_:)

Opens a control-mode connection for the duration of body, handing over the connection itself.

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. When body returns, 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 %output only 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.
  • Throws: TmuxError/connectionClosed if the connection ends before body, including when body detaches its own client.
Raises

0 declared, 0 inherited

Esc

Type to search.