background

package
v0.0.0-...-8b99d48 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package background contains an abstraction for running processes in the background.

Index

Constants

This section is empty.

Variables

View Source
var ErrUserKilled = xerrors.Errorf("daemon killed by user")

Functions

This section is empty.

Types

type Process

type Process struct {
	// contains filtered or unexported fields
}

Process is an abstraction for running a command as a background process.

func New

func New(ctx context.Context, log slog.Logger, binName, cmd string, args ...string) *Process

New returns an instantiated daemon. binName is the expected /proc/<pid>/cmdline value used for exit detection; pass cmd for plain invocations, or the post-exec binary name for exec wrappers (e.g. "dockerd" when cmd is "unshare ... -- sh -c 'exec dockerd ...'").

func (*Process) Restart

func (d *Process) Restart(ctx context.Context, binName, cmd string, args ...string) error

Restart kill the running process and reruns the command with the updated binName, cmd and args. See New for the meaning of binName.

func (*Process) Run

func (d *Process) Run() <-chan error

Run runs the command and waits for it to exit. It is a convenience function that combines both Start() and Wait().

func (*Process) Start

func (d *Process) Start() error

Start starts the daemon. It functions akin to ox/exec.Command.Start().

func (*Process) Wait

func (d *Process) Wait() <-chan error

Wait waits for the process to exit, returning the error on the provided channel.

Jump to

Keyboard shortcuts

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