command

package
v1.20.0-beta.11 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(cmd string) bool

func ExistsForUser

func ExistsForUser(cmd, user string) bool

func ForUser

func ForUser(cmd *exec.Cmd, userName string) error

func GetHome

func GetHome(userName string) (string, error)

func IsRunning

func IsRunning(pid string) (bool, error)

func Kill

func Kill(pid string) error

func KillTree

func KillTree(pid, treeName string) error

KillTree terminates the process and everything it spawned: the job or process group treeName identifies when set, otherwise the process alone.

func KillTreeAfterWorkerExit

func KillTreeAfterWorkerExit(pid, treeName, identity string) error

KillTreeAfterWorkerExit terminates descendants using the worker's saved session identity.

func KillTreeWithIdentity

func KillTreeWithIdentity(pid, treeName, identity string) error

KillTreeWithIdentity terminates a worker tree using its saved platform identity.

func ProcessTreeIdentity

func ProcessTreeIdentity(pid int) (string, error)

ProcessTreeIdentity returns the kernel identity used to distinguish a reused process ID.

func Quote

func Quote(args []string) string

func StartBackground added in v1.1.0

func StartBackground(commandName string, createCommand CreateCommand) error

StartBackground starts a background process unconditionally, without any once-guard. Use this for commands that must run on every invocation (e.g. postAttachCommand which runs on every attach per the devcontainer spec).

func StartBackgroundOnce

func StartBackgroundOnce(commandName string, createCommand CreateCommand) error

StartBackgroundOnce starts a background process, ensuring only one instance with the given commandName runs at a time. If a process is already running (determined by PID file), or the lock cannot be acquired, it returns nil.

Process output is redirected to TMPDIR/commandName.streams unless the command already has Stdout/Stderr configured. The PID is recorded in TMPDIR/commandName.pid. These files are not cleaned up on exit.

func StartSupervisedBackground

func StartSupervisedBackground(opts SupervisedStartOptions, createCommand CreateCommand) error

StartSupervisedBackground starts a detached worker with an owned process tree and publishes its reference before the launch is considered complete.

func WrapCommandError

func WrapCommandError(stdout []byte, err error) error

Types

type CreateCommand

type CreateCommand func() (*exec.Cmd, error)

type Error

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

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap added in v1.6.1

func (e *Error) Unwrap() error

type ProcessController

type ProcessController interface {
	Terminate(ProcessRef) error
	CleanupAfterExit(ProcessRef) error
}

ProcessController provides the two operations needed by task cancellation.

func DefaultProcessController

func DefaultProcessController() ProcessController

type ProcessRef

type ProcessRef struct {
	PID      int             `json:"pid,omitempty"`
	TreeKind ProcessTreeKind `json:"treeKind,omitempty"`
	TreeID   string          `json:"treeId,omitempty"`
	Identity string          `json:"identity,omitempty"`
}

ProcessRef is the persisted reference used to supervise a detached worker. TreeID and Identity are opaque outside this package.

type ProcessTreeKind

type ProcessTreeKind string

ProcessTreeKind identifies the platform primitive that owns a worker tree.

const (
	ProcessTreeLegacyPID  ProcessTreeKind = "legacy-pid"
	ProcessTreeUnixGroup  ProcessTreeKind = "unix-group-v1"
	ProcessTreeWindowsJob ProcessTreeKind = "windows-job-v1"
)

type SupervisedStartOptions

type SupervisedStartOptions struct {
	Name      string
	OnStarted func(ProcessRef) error
}

Jump to

Keyboard shortcuts

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