On this page
Server.withControlMode(attachingTo:_:)
- Declared in
- Server
- Package
- libtmux-swift
- Source
- Sources/LibTmux/ControlMode.swift
- withControlMode(attachingTo:_:) ( attachingTo : String , body : @escaping (ControlSession) async throws -> Result ) Result
-
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. 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.
- Raises
- Parameters:
0 declared, 0 inherited