Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

Swift API

method libtmux-swift latest

Server.withControlMode(attachingTo:_:)

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

Source and package
Qualified name
Server.withControlMode(attachingTo:_:)
Declared in
Server
Package
libtmux-swift
Source
Sources/LibTmux/ControlMode.swift
withControlMode( attachingTo: 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. 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.
Type parameters
Parameters
Raises

tmux command#

The tmux commands behind withControlMode(attachingTo:_:).

tmux C API#

The C declarations in tmux that implement these commands.

Esc

Type to search.

Reference previewOpen reference