{"id":21972817,"url":"https://github.com/agustinsrg/go-child-process-manager","last_synced_at":"2025-10-09T02:26:59.145Z","repository":{"id":59044748,"uuid":"529221250","full_name":"AgustinSRG/go-child-process-manager","owner":"AgustinSRG","description":"(Golang) Ensure all the child processes are killed if the main process is killed.","archived":false,"fork":false,"pushed_at":"2023-07-14T18:20:09.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T10:51:56.451Z","etag":null,"topics":["child-process","golang","kill","process"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/AgustinSRG/go-child-process-manager","language":"Go","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/AgustinSRG.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":"2022-08-26T10:56:19.000Z","updated_at":"2025-03-22T02:18:43.000Z","dependencies_parsed_at":"2024-06-20T06:00:01.631Z","dependency_job_id":null,"html_url":"https://github.com/AgustinSRG/go-child-process-manager","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/AgustinSRG/go-child-process-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Fgo-child-process-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Fgo-child-process-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Fgo-child-process-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Fgo-child-process-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AgustinSRG","download_url":"https://codeload.github.com/AgustinSRG/go-child-process-manager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Fgo-child-process-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000780,"owners_count":26082906,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["child-process","golang","kill","process"],"created_at":"2024-11-29T15:21:27.790Z","updated_at":"2025-10-09T02:26:59.119Z","avatar_url":"https://github.com/AgustinSRG.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Child process manager for go\n\nThis is a simple library to ensure all the child processes are killed if the main process is killed.\n\n[Documentation](https://pkg.go.dev/github.com/AgustinSRG/go-child-process-manager)\n\n## Usage\n\nImport the module\n\n```\ngo get github.com/AgustinSRG/go-child-process-manager\n```\n\nExample usage:\n\n```go\npackage main\n\nimport (\n\t\"os/exec\"\n\n\t// Import the module\n\tchild_process_manager \"github.com/AgustinSRG/go-child-process-manager\"\n)\n\nfunc main() {\n\t// The child process manager must be initialized before any child processes are created\n\terr := child_process_manager.InitializeChildProcessManager()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t// Call DisposeChildProcessManager() just before exiting the main process\n\tdefer child_process_manager.DisposeChildProcessManager()\n\n\t// Create a command (this is an example)\n\tcmd := exec.Command(\"ffmpeg\", \"-i\", \"input.mp4\", \"output.webm\")\n\n\t// Configure the command to be killed when the main process dies\n\terr = child_process_manager.ConfigureCommand(cmd)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Start the process\n\terr = cmd.Start()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Add process as a child process\n\terr = child_process_manager.AddChildProcess(cmd.Process)\n\tif err != nil {\n\t\tcmd.Process.Kill() // We must kill the process if this fails\n\t\tpanic(err)\n\t}\n\n\t// Wait for the process to finish\n\terr = cmd.Wait()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\n## Testing\n\nIn order to test the code, first go to the `test` folder.\n\n```sh\ncd test\n```\n\nThen, build the test binary:\n\n```sh\ngo get github.com/AgustinSRG/go-child-process-manager/test\ngo build\n```\n\nRun the test binary:\n\n```sh\n./test\n```\n\nAfter it finishes, it should print `SUCCESS | THE CHILD PROCESS IS DEAD`\n\nIf you want to test what happens without using this library, use the following:\n\n```sh\n./test --no-library\n```\n\nAfter it finishes, it should print `ERROR | THE CHILD PROCESS WAS ALIVE`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagustinsrg%2Fgo-child-process-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagustinsrg%2Fgo-child-process-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagustinsrg%2Fgo-child-process-manager/lists"}