# test.reap_abandoned_servers

- **Module:** test
- **Package:** libtmux
- **Language:** Rust
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/test.rs#L1078
- **Page:** https://libtmux.org/reference/rs/test-reap_abandoned_servers/

```
test.reap_abandoned_servers(older_than: Duration) -> Result<Vec<PathBuf>, TestServerError>
```

Kill tmux servers left behind by fixtures that never cleaned up.

A [`TestServer`] removes its own daemon and directory. One whose process
was killed mid-run cannot, and the daemon it left keeps running: each
holds a pseudo-terminal for every pane it has, and a system has a few
thousand. Enough abandoned runs and the next `fork` fails with `No space
left on device`, which reads as a bug in whatever ran next.

Only this crate's own fixtures are considered: a directory under
`/tmp/libtmux-rs-test`, owned by this user, holding a socket where a
fixture puts one. A tmux server started any other way -- including one belonging
to another libtmux on the same machine -- is never touched, so this cannot
reach a real session.

Abandonment is read from the process that made the fixture, not guessed
from a timestamp: each one records its owner, and a fixture is only reaped
once that process is gone. A recycled process id makes this skip a
leftover rather than reap a live one, which is the direction to fail in.
`older_than` is a second guard on top, for a fixture whose owner id has
been reused; pass `Duration::ZERO` to rely on the owner check alone.

# Errors

Returns an error when the temporary root cannot be read. A directory that
cannot be reaped is skipped rather than failing the sweep, because one
unreadable leftover should not stop the rest being cleared.

## Example

```rust
use std::time::Duration;

// Nothing this old is in use, so nothing a running test owns is at risk.
let reaped = libtmux::test::reap_abandoned_servers(Duration::from_secs(3600))?;
println!("reaped {} abandoned fixtures", reaped.len());
```
