proclifecycle

package
v0.2026205.742 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package proclifecycle is a stdlib-only leaf package (no deps beyond os/ os/signal/path/filepath/strings/sync/syscall/time) holding generic host-process lifecycle plumbing: catchable-signal-triggered cleanup hooks and a stale-temp-file sweep. It has ZERO business being named after VMs — relocated out of sdk/vmshared (FLOOR-SLIM mechanical batch, per an orchestrator ruling) once a consumer census showed it is used directly by charly/main.go AND by candy/plugin-enc, candy/plugin-secrets, candy/plugin-vm, candy/plugin-oci, and sdk/deploykit/localpkg.go — a genuinely shared leaf, never a VM-kit or a charly-core-only dependency. Mirrors the sdk/schemaconcat precedent: a stdlib-only leaf outside the named mechanism kits (kit/deploykit/buildkit/loaderkit/vmshared), so charly/main.go can import it directly without violating IMPORT-PURITY (a leaf is not a mechanism kit), and every kit (vmshared included) may import it too (kits may import leaves).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallSignalHandler

func InstallSignalHandler()

InstallSignalHandler arms the global signal handler exactly once. Subsequent calls are no-ops. On SIGTERM/SIGINT/SIGHUP it runs the registered temp cleanups AND the registered shutdown hooks (plugin-client reaping, etc.), then re-raises the signal so the process exits with the conventional 128+signum status code.

SIGKILL is not catchable (kernel-level). Leftover temps from a SIGKILL'd charly are caught by the next invocation's SweepStaleTemps; orphaned plugin servers from a SIGKILL'd charly self-terminate via the plugin SDK's parent-death watch (see plugin/sdk/parentwatch.go).

func RegisterShutdownHook

func RegisterShutdownHook(fn func())

RegisterShutdownHook registers fn to run on a catchable shutdown signal (SIGTERM/SIGINT/SIGHUP), in the signal handler, before it re-raises the signal and the process exits. It is the package-boundary seam that lets package main reap resources this package's signal handler cannot reference directly — notably charly's connected out-of-process plugin clients (providerRegistry.Close): a Ctrl-C'd / `systemctl stop`ped charly kills its plugin servers instead of orphaning them (the 77h-orphan leak). Hooks run in registration order; each MUST be best-effort and bounded (the handler is synchronous). A nil fn is a no-op.

func RegisterTempCleanup

func RegisterTempCleanup(path string)

RegisterTempCleanup registers path for cleanup on graceful shutdown (SIGTERM/SIGINT/SIGHUP). Existing `defer os.Remove(...)` callers keep working for normal exit; this is a SUPPLEMENTAL safety net for the ungraceful-but-catchable signal path. Empty path is a no-op.

func SweepStaleTemps

func SweepStaleTemps()

SweepStaleTemps removes /tmp/<prefix>* entries that are (a) NOT held open by any running process AND (b) older than sweepSafetyFloor AND (c) owned by the current user. Best-effort: never errors, never blocks. Called once from main().

func UnregisterTempCleanup

func UnregisterTempCleanup(path string)

UnregisterTempCleanup removes a path from the registry. Called by the existing defer-cleanup paths after they successfully os.Remove the file, so the registry doesn't accumulate stale entries in long- running charly processes (e.g. `charly mcp serve`).

Types

This section is empty.

Jump to

Keyboard shortcuts

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