subprocess

package
v0.0.0-...-288c4de Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotRunning = fmt.Errorf("The process isn't running")

ErrNotRunning is returned when performing an action against a stopped process.

Functions

This section is empty.

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

func ImportProcess(path string) (*Process, error)

ImportProcess imports a saved process into a subprocess object.

func NewProcess

func NewProcess(name string, args []string, stdoutPath string, stderrPath string) (*Process, error)

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) GetPid

func (p *Process) GetPid() (int64, error)

GetPid returns the pid for the given process object.

func (*Process) Reload

func (p *Process) Reload() error

Reload sends the SIGHUP signal to the given process object.

func (*Process) Restart

func (p *Process) Restart(ctx context.Context) error

Restart stop and starts the given process object.

func (*Process) Save

func (p *Process) Save(path string) error

Save will save the given process object to a YAML file. Can be imported at a later point.

func (*Process) SetApparmor

func (p *Process) SetApparmor(profile string)

SetApparmor allows setting the AppArmor profile.

func (*Process) SetCreds

func (p *Process) SetCreds(uid uint32, gid uint32)

SetCreds allows setting process credentials.

func (*Process) SetUserns

func (p *Process) SetUserns(userns *idmap.IdmapSet)

SetUserns allows running inside of a user namespace.

func (*Process) Signal

func (p *Process) Signal(signal int64) error

Signal will send a signal to the given process object given a signal value.

func (*Process) Start

func (p *Process) Start(ctx context.Context) error

Start will start the given process object.

func (*Process) StartWithFiles

func (p *Process) StartWithFiles(ctx context.Context, fds []*os.File) error

StartWithFiles will start the given process object with extra file descriptors.

func (*Process) Stop

func (p *Process) Stop() error

Stop will stop the given process object.

func (*Process) Wait

func (p *Process) Wait(ctx context.Context) (int64, error)

Wait will wait for the given process object exit code.

Jump to

Keyboard shortcuts

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