{"id":15893406,"url":"https://github.com/multimeric/libprocon","last_synced_at":"2025-10-20T12:18:23.635Z","repository":{"id":252538566,"uuid":"840736158","full_name":"multimeric/libprocon","owner":"multimeric","description":"Process connector library for C++: monitors processes being created and destroyed without root!","archived":false,"fork":false,"pushed_at":"2024-08-10T15:26:24.000Z","size":643,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T05:23:34.820Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://multimeric.github.io/libprocon/procon/procon_8h/","language":"C","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/multimeric.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}},"created_at":"2024-08-10T14:27:55.000Z","updated_at":"2024-08-10T15:26:26.000Z","dependencies_parsed_at":"2024-08-10T15:44:43.893Z","dependency_job_id":"9758c33d-aa15-4f88-a42b-e5ab73d5c981","html_url":"https://github.com/multimeric/libprocon","commit_stats":null,"previous_names":["multimeric/libprocon"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multimeric%2Flibprocon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multimeric%2Flibprocon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multimeric%2Flibprocon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multimeric%2Flibprocon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/multimeric","download_url":"https://codeload.github.com/multimeric/libprocon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246863822,"owners_count":20846317,"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-10-06T08:10:23.931Z","updated_at":"2025-10-20T12:18:18.565Z","avatar_url":"https://github.com/multimeric.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# procon\n\n## Installation\n\nIn CMake:\n```cmake\ninclude(FetchContent)\nFetchContent_Declare(\n    libprocon\n    GIT_REPOSITORY https://github.com/multimeric/libprocon.git\n)\nFetchContent_MakeAvailable(libprocon)\ntarget_link_libraries(\u003cMY TARGET\u003e PUBLIC libprocon)\n```\n\nThen in C++:\n```C++\n#include \"procon.h\"\n```\n\n## Usage\n\nCurrently the API consists of one single function: `proc_iter()`, which is a generator function that yields events:\n\n```C++\n#include \u003cstdio.h\u003e\n#include \"procon.h\"\n\nint main(){\n    // Continually listen for events\n    for (auto event: proc_iter()){\n        switch(event-\u003ewhat){\n            // Whenever a process exits, log it to stdout\n            case PROC_EVENT_EXIT:\n                {\n                    auto exit = event-\u003eevent_data.exit;\n                    std::cout \u003c\u003c \"PID: \" \u003c\u003c exit.process_pid \u003c\u003c \" exited with code \" \u003c\u003c exit.exit_code \u003c\u003c \"\\n\";\n                }\n            break;\n\n            default:\n            break;\n        }\n    }\n    return 0;\n}\n```\n\n## FAQ\n\n### Why use the process connector API instead of an alternative?\n\nThere aren't any alternative Linux APIs for process monitoring that meet the criteria I want:\n* Don't use polling\n* Can be run without root\n* Doesn't require unusual Linux kernel or system configuration\n* Returns the exit code and signals\n* Doesn't have to spawn the watched processes itself\n\n[`waitid()` and friends](https://man7.org/linux/man-pages/man2/waitpid.2.html) fail the last criteria: they can only be used on child processes.\n[Process accounting requires root to specifically enable it](https://man7.org/linux/man-pages/man8/accton.8.html).\n\n### Why C++?\n\nC already has a process connector library: the kernel's `cn_proc`. Rust is possibly a better language for this, but [I had some `bindgen` issues](https://github.com/yorodm/cnproc-rs/issues/9), so moved to C++.\n\n### Which Linux kernels support this?\n\n[`cn_proc` was enabled for non-root users in Linux 6.6](https://patchwork.kernel.org/project/netdevbpf/patch/20230719201821.495037-6-anjali.k.kulkarni@oracle.com/) (Thank you to the author and Oracle for supporting this!). This was released in October 2023. Technically you can use this library on earlier kernels, but if you have root available, there are better tools than this.\n\n### Why use generators?\n\nThis was the neatest API I could design.\nUsing a single \"receive\" function would mean creating and destroying the socket each invocation, whereas a generator can retain its state.\nI could export an array of functions for subscribing and then reading, but this isn't providing much abstraction and isn't very user friendly.\nUsing an iterator means more boilerplate and less elegant usage, especially if you don't want want to listen forever.\nFinally, using a generator means easy conversion to async/multithreaded support, without breaking the API in the future.\n\n### Why require such a high C++ standard?\n\nIn short, I wanted an elegant API and elegant implementation.\nC++ 20 gives me generators (see above), designated initializers etc.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultimeric%2Flibprocon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmultimeric%2Flibprocon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultimeric%2Flibprocon/lists"}