# libtmux::Server::wait_for

- **Module:** libtmux::Server
- **Package:** libtmux-cxx
- **Language:** C++
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-cxx/blob/85e8bd603a322dc32bb8b9aeb1a72bcf36945f1d/include/libtmux/server.hpp#L183
- **Page:** https://libtmux.org/reference/cxx/libtmux-server-wait_for/

```
libtmux::Server::wait_for(channel: std::string_view, timeout: std::optional< std::chrono::milliseconds > = {}) -> expected< void, CommandFailure >
```

Block until someone signals this channel, or the deadline passes.

tmux latches a signal: one sent while nobody is waiting satisfies the next wait rather than being lost. That makes signal-before-wait safe, and it also means a stale signal can release a later waiter, so a channel is worth naming for one exchange rather than reusing.

A server that dies under a waiter makes tmux exit zero, which is indistinguishable from being signalled — a caller would carry on as though the other side had spoken. This reports that as a failure instead, which is the reason to prefer it over running the command.
