On this page
test.reap_abandoned_servers
- Module
- test
- Package
- libtmux
- Source
- crates/libtmux/src/test.rs
- 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 nextforkfails withNo 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_thanis a second guard on top, for a fixture whose owner id has been reused; passDuration::ZEROto 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.
Examples
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());
0 declared, 0 inherited