subreaper

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package subreaper provides a portable wrapper around the "subreaper" / orphan-cleanup primitive on each supported OS:

  • Linux: prctl(PR_SET_CHILD_SUBREAPER) + SIGCHLD reaping
  • FreeBSD: procctl(PROC_REAP_ACQUIRE) + SIGCHLD reaping
  • macOS: no-op (orphans reparent to launchd)
  • Windows: kill-on-close Job Object; orphans die when this process exits and the OS releases the job handle

A typical lifecycle is:

if err := subreaper.Setup(); err != nil { ... }
go subreaper.Reap(ctx)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reap

func Reap(ctx context.Context)

Reap collects zombie child processes for the lifetime of ctx. It listens for SIGCHLD and drains all finished children on each tick. When run after Setup it also reaps descendants reparented to us via subreaper / procctl, keeping the process table clean.

func Setup

func Setup() error

Setup is a no-op on macOS: there is no PR_SET_CHILD_SUBREAPER nor procctl(PROC_REAP_ACQUIRE), and orphaned descendants reparent to launchd instead of this process.

Types

This section is empty.

Jump to

Keyboard shortcuts

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