# libtmux.pytest_plugin._reap_test_server

- **Module:** libtmux.pytest_plugin
- **Package:** libtmux
- **Language:** Python
- **Kind:** function
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/pytest_plugin.py#L28
- **Page:** https://libtmux.org/reference/py/libtmux-pytest_plugin-_reap_test_server/

```
libtmux.pytest_plugin._reap_test_server(socket_name: str | None) -> None
```

Kill the tmux daemon on ``socket_name`` and unlink the socket file.

Invoked from the :func:`server` and :func:`TestServer` fixture
finalizers to guarantee teardown even when the daemon has already
exited (``kill`` is a no-op then) and the socket file was left on
disk. tmux does not reliably ``unlink(2)`` its socket on
non-graceful exit, so ``/tmp/tmux-<uid>/`` otherwise accumulates
stale entries across test runs.

Conservative: suppresses ``LibTmuxException`` / ``OSError`` on both
the kill and the unlink. A finalizer that raises replaces the real
test failure with a cleanup error, and cleanup failures are not
actionable (socket already gone, permissions changed, race with a
concurrent pytest-xdist worker).
