Documentation
¶
Index ¶
- func Exists(cmd string) bool
- func ExistsForUser(cmd, user string) bool
- func ForUser(cmd *exec.Cmd, userName string) error
- func GetHome(userName string) (string, error)
- func IsRunning(pid string) (bool, error)
- func Kill(pid string) error
- func KillTree(pid, treeName string) error
- func KillTreeAfterWorkerExit(pid, treeName, identity string) error
- func KillTreeWithIdentity(pid, treeName, identity string) error
- func ProcessTreeIdentity(pid int) (string, error)
- func Quote(args []string) string
- func StartBackground(commandName string, createCommand CreateCommand) error
- func StartBackgroundOnce(commandName string, createCommand CreateCommand) error
- func StartSupervisedBackground(opts SupervisedStartOptions, createCommand CreateCommand) error
- func WrapCommandError(stdout []byte, err error) error
- type CreateCommand
- type Error
- type ProcessController
- type ProcessRef
- type ProcessTreeKind
- type SupervisedStartOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExistsForUser ¶
func KillTree ¶
KillTree terminates the process and everything it spawned: the job or process group treeName identifies when set, otherwise the process alone.
func KillTreeAfterWorkerExit ¶
KillTreeAfterWorkerExit terminates descendants using the worker's saved session identity.
func KillTreeWithIdentity ¶
KillTreeWithIdentity terminates a worker tree using its saved platform identity.
func ProcessTreeIdentity ¶
ProcessTreeIdentity returns the kernel identity used to distinguish a reused process ID.
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 ¶
Types ¶
type CreateCommand ¶
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
}