{"id":44605110,"url":"https://github.com/aretw0/procio","last_synced_at":"2026-02-26T11:00:03.008Z","repository":{"id":338337818,"uuid":"1157521680","full_name":"aretw0/procio","owner":"aretw0","description":"Lightweight, standalone Go module for robust process lifecycle management and interactive I/O.","archived":false,"fork":false,"pushed_at":"2026-02-23T19:35:13.000Z","size":82,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-24T00:11:57.224Z","etag":null,"topics":["context-aware","cross-platform","go","golang","interactive-cli","leak-free","pdeathsig","process-hygiene","process-management","signaling","terminal-io","windows-job-objects","zombie-processes"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aretw0.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-02-13T23:10:11.000Z","updated_at":"2026-02-23T19:35:17.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/aretw0/procio","commit_stats":null,"previous_names":["aretw0/procio"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/aretw0/procio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aretw0%2Fprocio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aretw0%2Fprocio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aretw0%2Fprocio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aretw0%2Fprocio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aretw0","download_url":"https://codeload.github.com/aretw0/procio/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aretw0%2Fprocio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29856790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T08:51:08.701Z","status":"ssl_error","status_checked_at":"2026-02-26T08:50:19.607Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["context-aware","cross-platform","go","golang","interactive-cli","leak-free","pdeathsig","process-hygiene","process-management","signaling","terminal-io","windows-job-objects","zombie-processes"],"created_at":"2026-02-14T10:34:53.056Z","updated_at":"2026-02-26T11:00:02.999Z","avatar_url":"https://github.com/aretw0.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# procio\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/aretw0/procio)](https://goreportcard.com/report/github.com/aretw0/procio)\n[![Go Reference](https://pkg.go.dev/badge/github.com/aretw0/procio.svg)](https://pkg.go.dev/github.com/aretw0/procio)\n[![License](https://img.shields.io/github/license/aretw0/procio.svg?color=red)](./LICENSE)\n[![Release](https://img.shields.io/github/release/aretw0/procio.svg?branch=main)](https://github.com/aretw0/procio/releases)\n\n`procio` is a lightweight, standalone set of composable primitives for safe process lifecycle and interactive I/O in Go.\n\nIt provides three core primitives:\n\n- **proc**: Leak-free process management (ensures child processes die when parent dies).\n- **termio**: Interruptible terminal I/O (handling interrupts and safe terminal handles).\n- **scan**: Robust input scanning with deterministic protection against \"Fake EOF\" signals on Windows.\n\n## Installation\n\n```bash\ngo get github.com/aretw0/procio\n```\n\n## Usage\n\n### Starting a Process Safely\n\n```go\nimport \"github.com/aretw0/procio/proc\"\n\ncmd := proc.NewCmd(ctx, \"long-running-worker\")\n// Uses Pdeathsig (Linux) or Job Objects (Windows) to enforce cleanup\nerr := cmd.Start()\n```\n\n### Reading Input Robustly (Hardened)\n\n```go\nimport \"github.com/aretw0/procio/scan\"\n\n// Binds scanner to process liveness for deterministic EOF detection\nscanner := scan.NewScanner(os.Stdin, scan.WithProcess(cmd))\nscanner.Start(ctx) \n```\n\n### Enabling TTY Cancellation\n\nFor interactive CLIs that need Ctrl+C cancellation support:\n\n```go\nimport (\n    \"context\"\n    \"github.com/aretw0/procio/scan\"\n)\n\nctx, cancel := context.WithCancel(context.Background())\ndefer cancel()\n\nscanner := scan.NewScanner(os.Stdin,\n    scan.WithInterruptible(), // Enables context cancellation via Ctrl+C\n    scan.WithLineHandler(func(line string) {\n        fmt.Println(\"Got:\", line)\n    }),\n)\n\nscanner.Start(ctx) // Returns when context is cancelled or EOF\n```\n\n### Chained Cancels\n\n`proc.NewCmd` integrates naturally with derived contexts, so cancellation hierarchies work as expected:\n\n```go\n// appCtx controls the whole application lifetime.\nappCtx, appCancel := context.WithCancel(context.Background())\ndefer appCancel()\n\n// subCtx adds a deadline for a specific subprocess.\nsubCtx, subCancel := context.WithTimeout(appCtx, 10*time.Second)\ndefer subCancel()\n\ncmd := proc.NewCmd(subCtx, \"worker\")\nif err := cmd.Start(); err != nil {\n    log.Fatal(err)\n}\ncmd.Wait()\n// worker is terminated when subCtx expires OR when appCtx is cancelled —\n// whichever comes first. Platform hygiene (Job Objects / Pdeathsig) is\n// still applied regardless of which signal arrives first.\n```\n\n### Advanced Features\n\n`procio` provides primitives for advanced process control:\n\n#### Pseudo-Terminals (PTY)\n\nWrap interactive applications:\n\n```go\nimport \"github.com/aretw0/procio/pty\"\n\ncmd := exec.CommandContext(ctx, \"vim\")\np, err := pty.StartPTY(cmd)\n// Forward p.Controller to/from host Stdin/Stdout\n```\n\n#### Streaming Telemetry\n\nMonitor processes in real-time (Linux \u0026 Windows):\n\n```go\nch, err := proc.Monitor(ctx, cmd, time.Second)\nfor m := range ch {\n    fmt.Printf(\"CPU: %.1f%% Mem: %d KB\\n\", m.CPUPercent, m.MemRSS/1024)\n}\n```\n\n## Observability\n\n`procio` is opinionated about specific mechanisms but unopinionated about logging/metrics.\nYou can inject your own observer:\n\n```go\nimport \"github.com/aretw0/procio\"\n\nprocio.SetObserver(myObserver)\n```\n\nSee [docs/RECIPES.md](./docs/RECIPES.md) for a complete `log/slog` adapter example.\n\n## License\n\nThis project is licensed under the terms of the [AGPL-3.0](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faretw0%2Fprocio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faretw0%2Fprocio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faretw0%2Fprocio/lists"}