# withTmuxServer(socketFileName:_:)

- **Package:** libtmux-swift
- **Language:** Swift
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-swift/blob/f02a4668570e1cc5198c941413750e021f42c214/Tests/TmuxFixture/TmuxFixture.swift#L47
- **Page:** https://libtmux.org/reference/swift/withtmuxserver(socketfilename-_-)/

```
withTmuxServer(socketFileName:_:)(socketFileName: String, body: (Server) async throws -> Result) -> Result
```

Runs `body` against a private tmux server and always kills it — including when this process is killed outright.

Each case gets its own socket, so cases never see each other's sessions and
teardown never touches a server it did not start. The server is bootstrapped
with one session named `bootstrap`: a tmux server exits as soon as its last
session goes away, so without one there is nothing to hold it open. Scope
assertions to the objects the case created rather than to the server being
otherwise empty.

## Raises

- `Result`
