| Crates.io | tokio-pager |
| lib.rs | tokio-pager |
| version | 1.0.1 |
| created_at | 2025-09-26 17:32:47.43774+00 |
| updated_at | 2025-10-07 00:04:30.117868+00 |
| description | An asynchronous, Tokio-friendly pager implementation |
| homepage | |
| repository | https://github.com/mdippery/tokio-pager |
| max_upload_size | |
| id | 1856273 |
| size | 27,515 |
Unfortunately, Rust's pager crate does not play nicely with Tokio. It leaves threads open after the Tokio runtime exits, resulting in a nasty I/O error after a CLI program using both pager and a Tokio runtime exits. This may be due to the fact that the pager crate actually runs the pager in the parent process, meaning that the Tokio runtime, in the child process, exits before the pager, leaving dangling file descriptors and the aforementioned I/O error from Tokio.
Enter tokio-pager. This crate exports a Pager struct that allows the
use of a pager subprocess in a way that plays nicely with Tokio.
Pager pipes its output to program specified in the $PAGERenvironment
variable, except under two conditions:
$PAGER is cat, /usr/bin/cat, or anything that
ends in /cat (/bin/cat, etc.), then the output is not paged at all
(cat is not launched).stdout is not a TTY, such as when output is being redirected to a
file, the output is not paged.Pager respects the value of the $LESS environment variable (with some
caveats—see PagerEnv::pager_env() for details).
Right now, tokio-pager only works with less, but support for other
pagers is planned in the future.