{"id":22325089,"url":"https://github.com/rogercoll/pid-set","last_synced_at":"2025-03-26T05:44:01.192Z","repository":{"id":232947070,"uuid":"784275294","full_name":"rogercoll/pid-set","owner":"rogercoll","description":"Command supervisor in Rust","archived":false,"fork":false,"pushed_at":"2024-04-12T15:57:20.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-20T14:52:51.283Z","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/rogercoll.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}},"created_at":"2024-04-09T14:29:49.000Z","updated_at":"2024-04-12T14:19:08.000Z","dependencies_parsed_at":"2024-04-12T16:14:02.881Z","dependency_job_id":"0e6c45d4-4c65-4772-959c-49a135a90df3","html_url":"https://github.com/rogercoll/pid-set","commit_stats":null,"previous_names":["rogercoll/pid-set"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogercoll%2Fpid-set","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogercoll%2Fpid-set/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogercoll%2Fpid-set/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogercoll%2Fpid-set/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rogercoll","download_url":"https://codeload.github.com/rogercoll/pid-set/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245598310,"owners_count":20641884,"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":"2024-12-04T02:10:09.313Z","updated_at":"2025-03-26T05:44:01.172Z","avatar_url":"https://github.com/rogercoll.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Crates.io][crates-badge]][crates-url]\n[![CI](https://github.com/rogercoll/pid-set/actions/workflows/test.yaml//badge.svg?branch=main)](https://github.com/rogercoll/pid-set/actions/workflows/test.yaml?query=branch%3Amain)\n[![Dependency status](https://deps.rs/repo/github/rogercoll/pid-set/status.svg)](https://deps.rs/repo/github/rogercoll/pid-set)\n\n\n[crates-badge]: https://img.shields.io/crates/v/pid-set.svg\n[crates-url]: https://crates.io/crates/pid-set\n\n# PID Set Library\n\nThe `pid_set` library provides tools for managing and monitoring process identifiers (PIDs) using epoll on Linux platforms. It utilizes epoll and pidfd to asynchronously notify when a process exits, offering a robust way to handle PID-related events.\n\n## Motivation\n\nThe primary motivation behind developing the PidSet crate stems from a limitation in Rust's standard library, particularly with the [std::process::Child struct](https://doc.rust-lang.org/std/process/struct.Child.html), which is used to represent child processes. The standard Child struct provides a [wait](https://doc.rust-lang.org/std/process/struct.Child.html#method.wait) and a [try_wait](https://doc.rust-lang.org/std/process/struct.Child.html#method.try_wait) method that blocks the entire system thread until the child process exits. This blocking behavior is not ideal for efficiently managing multiple child processes within a single thread.\n\nThe PidSet crate addresses this by leveraging Linux's epoll and pidfd functionalities, enabling non-blocking and asynchronous monitoring of multiple processes. By using epoll, PidSet allows a program to \"watch\" multiple child processes and receive notifications about changes in their state (like termination), without the need of blocking a thread for each child process. This is particularly useful in applications that need to manage several child processes concurrently without dedicating a separate thread to each process just to wait for its completion.\n\n### Man pages\n - https://man7.org/linux/man-pages/man2/pidfd_open.2.html\n - https://man7.org/linux/man-pages/man2/epoll_create.2.html\n - https://man7.org/linux/man-pages/man2/epoll_ctl.2.html\n\n## Features\n\n- **Manage Multiple PIDs**: Track and manage multiple process identifiers easily.\n- **Asynchronous Monitoring**: Use epoll for efficient event notification.\n- **Error Handling**: Includes comprehensive error handling to manage system call failures gracefully.\n\n### WIP features\n\n- [ ] Insert/delete function\n- [ ] Add duration parameter to wait functions (breaking change)\n\n## Prerequisites\n\nThis library is intended for use on Linux systems with support for `epoll` and `pidfd_open`. Ensure your system meets these requirements before using the library.\n\n\n## Installation\n\nAdd `pid_set` to your `Cargo.toml` dependencies:\n\n```toml\n[dependencies]\npid_set = \"0.1.0\"\n```\n\n## Usage\n\n```rust\nuse pid_set::{PidSet, PidSetError};\n\nfn main() -\u003e Result\u003c(), PidSetError\u003e {\n    // Example PIDs to monitor\n    let pids = vec![1234, 5678];\n    let mut pid_set = PidSet::new(pids);\n\n    // Wait for any one PID to exit\n    pid_set.wait_any()?;\n\n    // Clean up\n    pid_set.close()?;\n    Ok(())\n}\n```\n\n## API\n\n - `PidSet::new(pids)`: Create a new PidSet with the specified PIDs.\n - `PidSet::wait_any()`: Wait for any one PID to exit.\n - `PidSet::wait_all()`: Wait for all PIDs to exit.\n - `PidSet::close()`: Close the epoll file descriptor and clean up resources.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogercoll%2Fpid-set","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frogercoll%2Fpid-set","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogercoll%2Fpid-set/lists"}