# LibTmux.Server.withRuntime

- **Package:** libtmux-haskell
- **Language:** Haskell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-haskell/blob/663e212622a02aa74a9bdc8ff71e2b45fcb1d4d5/src/LibTmux/Server.hs#L101
- **Page:** https://libtmux.org/en/haskell/latest/reference/libtmux-server-v-withruntime/

```haskell
withRuntime :: (Runtime -> IO a) -> IO a
```

Signature types: [`Runtime`](/en/haskell/latest/reference/libtmux-server-t-runtime/), [`IO`](https://hackage.haskell.org/package/base-4.22.0.0/docs/Prelude.html#t:IO).

Own a Runtime for the callback and perform bounded cleanup afterward.
 Closing it retires every adopted handle; application-owned threads remain
 the application's responsibility. Late adoption fails with [`RuntimeClosed`](/en/haskell/latest/reference/libtmux-server-v-runtimeclosed/).
 The daemon remains running.

Callback failures and cancellation keep their original exception class.
 Incomplete cleanup retains a [`CleanupRecovery`](/en/haskell/latest/reference/libtmux-server-t-cleanuprecovery/) in the exception context;
 use [`tryTmux`](/en/haskell/latest/reference/libtmux-server-v-trytmux/) and [`cleanupRecoveries`](/en/haskell/latest/reference/libtmux-server-v-cleanuprecoveries/) to keep that responsibility reachable.

## Referenced declarations

- [`LibTmux.Server.Runtime`](/en/haskell/latest/reference/libtmux-server-t-runtime/) (data type)

## Guides

Pages that discuss `withRuntime`.

- [Shared Runtime scopes](/en/haskell/latest/guides/shared-runtime/)
- [Implementation status](/en/haskell/latest/guides/status/)
