# io.github.libtmux.kotlin.withPrivateServer

- **Module:** io.github.libtmux.kotlin
- **Package:** io.github.libtmux:libtmux-kotlin
- **Language:** Kotlin
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-java/blob/4d77001ac74cd9b7f66d1a56319a97ff6e0b2cd5/libtmux-kotlin/src/main/kotlin/io/github/libtmux/kotlin/Scopes.kt#L34
- **Page:** https://libtmux.org/en/kotlin/latest/reference/io-github-libtmux-kotlin-withprivateserver/

```
public suspend fun <R> withPrivateServer(
    launch: ServerLaunch = ServerLaunch.builder().build(),
    policy: ExecutionPolicy =
        ExecutionPolicy.default(ServerConfig.builder().build()),
    block: suspend (Server) -> R,
): R
```

Starts a private tmux server, runs [block], and ends the server — even if [block] throws or is cancelled. Closing it removes the server's directory and throws if the server still answers.

## Type parameters

- `R`

## Parameters

- `launch` (`ServerLaunch`)
  Default: `ServerLaunch.builder().build()`.
- `policy` (`ExecutionPolicy`)
  Default: `ExecutionPolicy.default(ServerConfig.builder().build())`.
- `block` (`suspend`)
