process

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package process provides handles on long-lived processes such as VMMs, started or adopted, that report when the process exits.

Index

Constants

This section is empty.

Variables

View Source
var ErrExitStatusUnknown = errors.New("exit status unavailable for an adopted process")

ErrExitStatusUnknown is the exit error of an adopted process. Only a process's parent can collect its exit status, and an adopted process was started by a previous daemon.

Functions

This section is empty.

Types

type Process

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

Process is a handle on a supervised process. Its methods are safe for concurrent use.

func Attach

func Attach(pid int, arg string) (*Process, error)

Attach adopts a running process the daemon did not start, such as a VMM that outlived the previous daemon. It pins the process with a pidfd and checks that arg is on its command line, so a reused PID is not mistaken for it.

func Start

func Start(cmd *exec.Cmd) (*Process, error)

Start starts cmd and returns a handle on it. The process is reaped as soon as it exits, so it never lingers as a zombie, and its exit status is kept for Err.

func (*Process) Done

func (p *Process) Done() <-chan struct{}

Done returns a channel that is closed when the process exits.

func (*Process) Err

func (p *Process) Err() error

Err reports why the process exited: nil for a clean exit, an *exec.ExitError for a child that failed or was killed, and ErrExitStatusUnknown for an adopted process. It must only be called after Done is closed.

func (*Process) Kill

func (p *Process) Kill() error

Kill sends SIGKILL. Killing a process that has already exited is not an error: the caller wanted it gone, and it is.

func (*Process) PID

func (p *Process) PID() int

PID returns the process ID.

func (*Process) Terminate

func (p *Process) Terminate()

Terminate kills the process and waits for it to exit.

Jump to

Keyboard shortcuts

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