{"id":22770070,"url":"https://github.com/devolo/childprocess","last_synced_at":"2025-07-15T07:38:49.177Z","repository":{"id":97942805,"uuid":"247713939","full_name":"devolo/childprocess","owner":"devolo","description":"Child process management","archived":false,"fork":false,"pushed_at":"2020-03-17T12:03:40.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-30T11:41:39.302Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devolo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-03-16T13:48:03.000Z","updated_at":"2020-03-17T12:03:42.000Z","dependencies_parsed_at":"2023-07-03T13:30:48.144Z","dependency_job_id":null,"html_url":"https://github.com/devolo/childprocess","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devolo/childprocess","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devolo%2Fchildprocess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devolo%2Fchildprocess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devolo%2Fchildprocess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devolo%2Fchildprocess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devolo","download_url":"https://codeload.github.com/devolo/childprocess/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devolo%2Fchildprocess/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265418484,"owners_count":23761822,"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-11T15:19:19.997Z","updated_at":"2025-07-15T07:38:49.169Z","avatar_url":"https://github.com/devolo.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Child Process Management Library\n\nFeatures:\n\n* Run a child process in the background\n* Specify exact parameters, not a shell command line\n* Write into the process' standard input\n* Read from the process' standard output and standard error\n* Wait until the process has terminated\n* Get the process' exit status\n* In short, encapsulates the Unix fork/exec/kill/wait system calls\n\nAlso:\n\n* Send a termination signal to the process (in the dtor)\n* Run an initialization function in the child process\n* Thread-safe\n* Exception-safe\n* Can be used instead of system(3) and popen(3) in  [CERT](https://en.wikipedia.org/wiki/CERT_C_Coding_Standard)-compliant applications\n\nPrerequisites:\n\n* C++17\n* [Boost](https://www.boost.org/)\n* Unix-like system\n\n## How to build and run the test program\n\nThis repository contains the child process library ([childprocess.hpp](childprocess.hpp), [childprocess.cpp](childprocess.cpp)) together with a Boost.Test unit test program. To build and run the unit tests:\n\n    $ mkdir build\n    $ cd build\n    $ cmake ..\n    $ make\n    $ make test\n\n## How to use it in your own projects\n\nCopy [childprocess.hpp](childprocess.hpp) and [childprocess.cpp](childprocess.cpp) to locations of your choise and add them to your build settings. Install and link with boost (see [CMakeLists.txt](CMakeLists.txt) for reference).\n\n## Examples\n\nReference code only. For complete examples refer to the unit test program ([test.cpp](test.cpp)).\n\n### Start a process and wait for termination\n\nRun `make -j test`, wait for completion, and check exit status.\n\n```cpp\n#include \u003cchildprocess.hpp\u003e\n\nauto chld = sdb::ChildProcess(\"/usr/bin/make\", { \"-j\", \"test\" });\nconst auto status = child.join();\nif (status!=0) {\n    // Failed\n}\n```\n\n### Write to stdin, read from stdout\n\nRun sed to convert `Hello world` into `Good night world`.\n\n```cpp\n#include \u003cchildprocess.hpp\u003e\n\nauto chld = sdb::ChildProcess(\n    \"/bin/sed\",\n    { \"s/Hello/Good night/g\" },\n    sdb::ChildProcess::IN | sdb::ChildProcess::OUT\n);\n\nauto in = chld.make_stdin([\u0026data](std::ostream\u0026 os) {\n    os \u003c\u003c \"Hello world\\n\";\n});\n\nstd::string input;\nauto out = chld.get_stdout([\u0026input](std::istream\u0026 is) {\n    input.assign(std::istreambuf_iterator\u003cchar\u003e(is),std::istreambuf_iterator\u003cchar\u003e());\n});\n\nin.get();\nout.get();\n\nconst auto status = chld.join();\nif (status!=0) {\n    // Failed\n}\n\n// Now input is \"Good night world\"\n```\n\n---\n*Wolfram Rösler • wolfram@roesler-ac.de • https://gitlab.com/wolframroesler • https://twitter.com/wolframroesler • https://www.linkedin.com/in/wolframroesler/*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevolo%2Fchildprocess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevolo%2Fchildprocess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevolo%2Fchildprocess/lists"}