go-container/specs/internal/proc.md

2.6 KiB

proc

Import: dappco.re/go/core/container/internal/proc Files: 1

Types

Process

type Process struct

Lightweight wrapper around an OS process ID.

  • Pid int: Operating-system process ID.

Command

type Command struct

Minimal process runner built directly on syscall.StartProcess.

  • Path string: Executable name or path to start.
  • Args []string: Full argument vector passed to the child process, including the command name at index 0.
  • Dir string: Working directory for the child process.
  • Env []string: Child environment. When nil, Start uses Environ().
  • Stdin io.Reader: Reader wired to child stdin when it exposes a file descriptor.
  • Stdout io.Writer: Writer wired to child stdout when it exposes a file descriptor.
  • Stderr io.Writer: Writer wired to child stderr when it exposes a file descriptor.
  • Process *Process: Populated after Start succeeds.

Functions

Top-Level Functions

  • Environ() []string: Returns the current process environment from syscall.Environ.
  • NewCommandContext(ctx context.Context, name string, args ...string) *Command: Constructs a command with the supplied context and an argument vector beginning with name.
  • NewCommand(name string, args ...string) *Command: Shorthand for NewCommandContext(context.Background(), name, args...).
  • LookPath(name string) (string, error): Resolves an executable path from PATH using PS as the path separator when set, or validates a direct path when name already contains a slash or backslash.

Process

  • (*Process).Kill() error: Sends SIGKILL to the process when Pid is valid, and otherwise does nothing.
  • (*Process).Signal(sig syscall.Signal) error: Sends the requested signal when Pid is valid, and otherwise does nothing.

Command

  • (*Command).StdoutPipe() (io.ReadCloser, error): Creates a stdout pipe that must be requested before Start.
  • (*Command).StderrPipe() (io.ReadCloser, error): Creates a stderr pipe that must be requested before Start.
  • (*Command).Start() error: Resolves the executable, maps stdin/stdout/stderr to real file descriptors or /dev/null, starts the child with syscall.StartProcess, closes child pipe ends in the parent, and arranges for context cancellation to kill the process.
  • (*Command).Run() error: Calls Start and then Wait.
  • (*Command).Output() ([]byte, error): Captures stdout through StdoutPipe, starts the process, reads all output, waits for exit, and returns any read or process error.
  • (*Command).Wait() error: Waits on the child process with syscall.Wait4, caches the result, and returns an error for non-zero exit status or terminating signals.