Documentation
¶
Index ¶
- Variables
- func NewRunError(cmd string, args []string, err error, stdout *bytes.Buffer, ...) error
- func RunCommand(name string, arg ...string) (string, error)
- func RunCommandCLocale(name string, arg ...string) (string, error)
- func RunCommandContext(ctx context.Context, name string, arg ...string) (string, error)
- func RunCommandInheritFds(ctx context.Context, filesInherit []*os.File, name string, arg ...string) (string, error)
- func RunCommandSplit(ctx context.Context, env []string, filesInherit []*os.File, name string, ...) (string, string, error)
- func RunCommandWithFds(ctx context.Context, stdin io.Reader, stdout io.Writer, name string, ...) error
- func TryRunCommand(name string, arg ...string) (string, error)
- type Process
- func (p *Process) GetPid() (int64, error)
- func (p *Process) Reload() error
- func (p *Process) Restart(ctx context.Context) error
- func (p *Process) Save(path string) error
- func (p *Process) SetApparmor(profile string)
- func (p *Process) SetCreds(uid uint32, gid uint32)
- func (p *Process) SetUserns(uidMap []syscall.SysProcIDMap, gidMap []syscall.SysProcIDMap)
- func (p *Process) Signal(signal int64) error
- func (p *Process) Start(ctx context.Context) error
- func (p *Process) StartWithFiles(ctx context.Context, fds []*os.File) error
- func (p *Process) Stop() error
- func (p *Process) Wait(ctx context.Context) (int64, error)
- type RunError
Constants ¶
This section is empty.
Variables ¶
var ErrNotRunning = fmt.Errorf("The process isn't running")
ErrNotRunning is returned when performing an action against a stopped process.
Functions ¶
func NewRunError ¶
func NewRunError(cmd string, args []string, err error, stdout *bytes.Buffer, stderr *bytes.Buffer) error
NewRunError returns new RunError.
func RunCommand ¶
RunCommand runs a command with optional arguments and returns stdout. If the command fails to start or returns a non-zero exit code then an error is returned containing the output of stderr. Deprecated: Use RunCommandContext.
func RunCommandCLocale ¶
RunCommandCLocale runs a command with a LC_ALL=C.UTF-8 and LANGUAGE=en environment set with optional arguments and returns stdout. If the command fails to start or returns a non-zero exit code then an error is returned containing the output of stderr.
func RunCommandContext ¶
RunCommandContext runs a command with optional arguments and returns stdout. If the command fails to start or returns a non-zero exit code then an error is returned containing the output of stderr.
func RunCommandInheritFds ¶
func RunCommandInheritFds(ctx context.Context, filesInherit []*os.File, name string, arg ...string) (string, error)
RunCommandInheritFds runs a command with optional arguments and passes a set of file descriptors to the newly created process, returning stdout. If the command fails to start or returns a non-zero exit code then an error is returned containing the output of stderr.
func RunCommandSplit ¶
func RunCommandSplit(ctx context.Context, env []string, filesInherit []*os.File, name string, arg ...string) (string, string, error)
RunCommandSplit runs a command with a supplied environment and optional arguments and returns the resulting stdout and stderr output as separate variables. If the supplied environment is nil then the default environment is used. If the command fails to start or returns a non-zero exit code then an error is returned containing the output of stderr too.
Types ¶
type Process ¶
type Process struct { Name string `yaml:"name"` Args []string `yaml:"args,flow"` Apparmor string `yaml:"apparmor"` PID int64 `yaml:"pid"` Stdin io.ReadCloser `yaml:"-"` Stdout io.WriteCloser `yaml:"-"` Stderr io.WriteCloser `yaml:"-"` UID uint32 `yaml:"uid"` GID uint32 `yaml:"gid"` SetGroups bool `yaml:"set_groups"` SysProcAttr *syscall.SysProcAttr // contains filtered or unexported fields }
Process struct. Has ability to set runtime arguments.
func ImportProcess ¶
ImportProcess imports a saved process into a subprocess object.
func NewProcess ¶
NewProcess is a constructor for a process object. Represents a process with argument config. stdoutPath and stderrPath arguments are optional. Returns an address to process.
func NewProcessWithFds ¶
func NewProcessWithFds(name string, args []string, stdin io.ReadCloser, stdout io.WriteCloser, stderr io.WriteCloser) *Process
NewProcessWithFds is a constructor for a process object. Represents a process with argument config. Returns an address to process.
func (*Process) Save ¶
Save will save the given process object to a YAML file. Can be imported at a later point.
func (*Process) SetApparmor ¶
SetApparmor allows setting the AppArmor profile.
func (*Process) SetUserns ¶
func (p *Process) SetUserns(uidMap []syscall.SysProcIDMap, gidMap []syscall.SysProcIDMap)
SetUserns allows running inside of a user namespace.
func (*Process) Signal ¶
Signal will send a signal to the given process object given a signal value.
func (*Process) StartWithFiles ¶
StartWithFiles will start the given process object with extra file descriptors.