procio

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2026 License: AGPL-3.0 Imports: 1 Imported by: 1

README

procio

procio is a lightweight, standalone Go module for robust process lifecycle management and interactive I/O.

It provides three core primitives:

  • proc: Leak-free process management (ensures child processes die when parent dies).
  • termio: Interactive terminal I/O (handling interrupts, raw mode, and virtual terminals).
  • scan: Robust input scanning with protection against "Fake EOF" signals on Windows.

Installation

go get github.com/aretw0/procio

Usage

starting a process safely
import "github.com/aretw0/procio/proc"

cmd := exec.Command("long-running-worker")
// Uses Pdeathsig (Linux) or Job Objects (Windows) to enforce cleanup
err := proc.Start(cmd)
Reading Input Robustly
import "github.com/aretw0/procio/scan"

scanner := scan.NewScanner(os.Stdin)
scanner.Start(ctx) // Respects context cancellation and handles transient interrupts

Observability

procio is opinionated about specific mechanisms but unopinionated about logging/metrics. You can inject your own observer:

import "github.com/aretw0/procio"

procio.SetObserver(myObserver)

Documentation

Overview

Package procio is the root package for robust process I/O and signaling primitives.

It provides a platform-agnostic way to handle process execution and terminal input with safety guarantees (like leak-free process termination using Job Objects on Windows and Pdeathsig on Linux).

Subpackages

  • proc: Process management and lifecycle guarantees.
  • scan: Context-aware parsing of input streams (Scanner).
  • termio: Terminal I/O utilities and interruptible readers.

Observability

procio does not depend on any logging library. Instead, it exposes an Observer interface that you can implement to bridge logs and metrics to your preferred system.

Index

Constants

This section is empty.

Variables

View Source
var Version string

Functions

func SetObserver

func SetObserver(o Observer)

SetObserver configures the global observer for process events.

Types

type Observer

type Observer interface {
	OnProcessStarted(pid int)
	OnProcessFailed(err error)
	LogDebug(msg string, args ...any)
	LogWarn(msg string, args ...any)
	LogError(msg string, args ...any)
}

Observer allows external packages to plug in observability (logs, metrics) without coupling this module to specific implementations.

func GetObserver

func GetObserver() Observer

GetObserver returns the current global observer. Useful for sub-packages to access the shared observer.

Directories

Path Synopsis
examples
basic command
Package proc provides platform-agnostic process management with safety guarantees.
Package proc provides platform-agnostic process management with safety guarantees.
Package scan provides a robust, context-aware command and line scanner.
Package scan provides a robust, context-aware command and line scanner.
Package termio provides interruptible I/O primitives and terminal handling.
Package termio provides interruptible I/O primitives and terminal handling.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL