reaper

package
v0.27.3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package reaper contains logic for reaping subprocesses. It is specifically used in the agent to avoid the accumulation of zombie processes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForkReap

func ForkReap(opt ...Option) error

ForkReap spawns a goroutine that reaps children. In order to avoid complications with spawning `exec.Commands` in the same process that is reaping, we forkexec a child process. This prevents a race between the reaper and an exec.Command waiting for its process to complete. The provided 'pids' channel may be nil if the caller does not care about the reaped children PIDs.

func IsInitProcess

func IsInitProcess() bool

IsInitProcess returns true if the current process's PID is 1.

Types

type Option added in v0.7.4

type Option func(o *options)

func WithCatchSignals added in v0.17.2

func WithCatchSignals(sigs ...os.Signal) Option

WithCatchSignals sets the signals that are caught and forwarded to the child process. By default no signals are forwarded.

func WithExecArgs added in v0.7.4

func WithExecArgs(args ...string) Option

WithExecArgs specifies the exec arguments for the fork exec call. By default the same arguments as the parent are used as dictated by os.Args. Since ForkReap calls a fork-exec it is the responsibility of the caller to avoid fork-bombing oneself.

func WithPIDCallback added in v0.7.4

func WithPIDCallback(ch reap.PidCh) Option

WithPIDCallback sets the channel that reaped child process PIDs are pushed onto.

Jump to

Keyboard shortcuts

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