{"id":25541519,"url":"https://github.com/bbqsrc/subterm","last_synced_at":"2026-02-04T09:30:19.196Z","repository":{"id":270128111,"uuid":"909413140","full_name":"bbqsrc/subterm","owner":"bbqsrc","description":"A library for managing pools of interactive subprocesses","archived":false,"fork":false,"pushed_at":"2025-01-05T15:53:25.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T16:56:12.298Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bbqsrc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["bbqsrc"],"custom":"https://necessary.nu"}},"created_at":"2024-12-28T16:21:19.000Z","updated_at":"2025-01-05T15:53:29.000Z","dependencies_parsed_at":"2024-12-28T17:33:33.884Z","dependency_job_id":null,"html_url":"https://github.com/bbqsrc/subterm","commit_stats":null,"previous_names":["bbqsrc/subterm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbqsrc%2Fsubterm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbqsrc%2Fsubterm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbqsrc%2Fsubterm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbqsrc%2Fsubterm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bbqsrc","download_url":"https://codeload.github.com/bbqsrc/subterm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239793100,"owners_count":19697891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-20T06:37:57.068Z","updated_at":"2026-02-04T09:30:19.114Z","avatar_url":"https://github.com/bbqsrc.png","language":"Rust","readme":"# Subterm\n\nA Rust library for efficiently managing pools of interactive subprocesses with async support.\n\n[![Crates.io](https://img.shields.io/crates/v/subterm.svg)](https://crates.io/crates/subterm)\n[![Documentation](https://docs.rs/subterm/badge.svg)](https://docs.rs/subterm)\n[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/subterm.svg)](#license)\n\n## Features\n\n- **Efficient Process Pool Management**: Maintain a pool of reusable subprocess instances\n- **Async/Await Support**: Built on tokio for asynchronous operation\n- **Fair Queue Management**: Uses a channel-based queuing system for fair process allocation\n- **Interactive Process Control**: Read from and write to subprocess stdin/stdout\n- **Automatic Process Recovery**: Dead processes are automatically replaced\n- **Resource Control**: Limit the maximum number of concurrent processes\n\n## Usage\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nsubterm = \"0.0.1\"\n```\n\n### Using the Process Pool\n\n```rust\nuse subterm::{SubprocessPool, Result};\nuse tokio::process::Command;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c()\u003e {\n    // Create a pool of 4 processes\n    let pool = SubprocessPool::new(|| {\n        let mut cmd = Command::new(\"your_interactive_program\");\n        cmd.arg(\"--some-flag\");\n        cmd\n    }, 4).await?;\n\n    // Acquire a process from the pool\n    let mut process = pool.acquire().await?;\n    \n    // Interact with the process\n    process.write_line(\"some input\").await?;\n    let response = process.read_line().await?;\n    println!(\"Got response: {}\", response);\n    \n    Ok(())\n}\n```\n\n### Direct Subprocess Usage\n\nYou can also create and manage subprocesses directly without using the pool:\n\n```rust\nuse std::sync::Arc;\nuse subterm::{Subprocess, Result};\nuse tokio::process::Command;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c()\u003e {\n    let mut process = Subprocess::new(|| {\n        let mut cmd = Command::new(\"your_interactive_program\");\n        cmd.arg(\"--some-flag\");\n        cmd\n    })?;\n    \n    // Interact with the process\n    process.write_line(\"hello\").await?;\n    let response = process.read_line().await?;\n    println!(\"Got response: {}\", response);\n    \n    // Read until a specific delimiter\n    process.write_bytes(b\"part1:part2\\n\").await?;\n    let response = process.read_bytes_until(b':').await?;\n    \n    // Close stdin when done\n    process.close_stdin();\n    \n    Ok(())\n}\n```\n\n## License\n\nLicensed under either of:\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contributing\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","funding_links":["https://github.com/sponsors/bbqsrc","https://necessary.nu"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbqsrc%2Fsubterm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbqsrc%2Fsubterm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbqsrc%2Fsubterm/lists"}