Documentation ¶
Overview ¶
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file expect in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file expect in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file expect in compliance with the License.
Index ¶
- func ParseInterfaceArgs(face interface{}, args ...string) ([]string, error)
- type ExecOption
- func WithDetach(detach bool) ExecOption
- func WithEnvKey(key, val string) ExecOption
- func WithOnExitCallback(callback func(int)) ExecOption
- func WithStderr(stderr io.Writer) ExecOption
- func WithStderrCallback(stderrcb io.Writer) ExecOption
- func WithStdin(stdin io.Reader) ExecOption
- func WithStdout(stdout io.Writer) ExecOption
- func WithStdoutCallback(stdoutcb io.Writer) ExecOption
- type ExecOptions
- type Executable
- type Process
- func (e *Process) Cmd() *exec.Cmd
- func (e *Process) Cmdline() string
- func (e *Process) Kill() error
- func (e *Process) Pid() (int, error)
- func (e *Process) Release() error
- func (e *Process) Signal(signal syscall.Signal) error
- func (e *Process) Start(ctx context.Context) error
- func (e *Process) StartAndWait(ctx context.Context) error
- func (e *Process) Wait() error
- type SequentialProcesses
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseInterfaceArgs ¶
ParseInterfaceArgs returns the array of arguments detected from an interface with tag annotations `flag`
Types ¶
type ExecOption ¶
type ExecOption func(eo *ExecOptions) error
func WithDetach ¶
func WithDetach(detach bool) ExecOption
func WithEnvKey ¶
func WithEnvKey(key, val string) ExecOption
WithEnvKey adds an additional environment by its key and value
func WithOnExitCallback ¶
func WithOnExitCallback(callback func(int)) ExecOption
WithOnExitCallback sets callback method where its only parameter is the exit code returned by the process. This method can be called multiple times.
func WithStderr ¶
func WithStderr(stderr io.Writer) ExecOption
WithStderr sets the primary stderr for the process
func WithStderrCallback ¶
func WithStderrCallback(stderrcb io.Writer) ExecOption
func WithStdin ¶
func WithStdin(stdin io.Reader) ExecOption
WithStdin sets the primary stdin for the process
func WithStdout ¶
func WithStdout(stdout io.Writer) ExecOption
WithStdout sets the primary stdout for the process
func WithStdoutCallback ¶
func WithStdoutCallback(stdoutcb io.Writer) ExecOption
WithStdoutCallback adds a callback which will be
type ExecOptions ¶
type ExecOptions struct {
// contains filtered or unexported fields
}
func NewExecOptions ¶
func NewExecOptions(eopts ...ExecOption) (*ExecOptions, error)
NewExecOptions accepts a series of options and returns a rendered *ExecOptions structure
type Executable ¶
type Executable struct {
// contains filtered or unexported fields
}
func NewExecutable ¶
func NewExecutable(bin string, face interface{}, args ...string) (*Executable, error)
NewExecutable accepts an input argument bin which is the path or executable name to be ultimately executed. An optional positional argument args can be provided which is of an interface type. The interface can use the attribute annotation tags `flag:"--myarg"` to aid serialization and organization of the executable's command-line arguments. The type of the attribute will derive what is passed to the flag.
func (*Executable) Args ¶
func (e *Executable) Args() []string
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
func NewProcess ¶
func NewProcess(bin string, args []string, eopts ...ExecOption) (*Process, error)
NewProcess prepares a process to be executed from a given binary name and optional execution options
func NewProcessFromExecutable ¶
func NewProcessFromExecutable(executable *Executable, eopts ...ExecOption) (*Process, error)
NewProcessFromExecutable prepares a process to be executed from a given *Executable object and optional execution options
func (*Process) Kill ¶
Kill sends a SIGKILL to the running process. If this fails, for example if the process is not running, this will return an error.
func (*Process) Release ¶ added in v0.6.0
Release releases any resources associated with the process rendering it unusable in the future. Release only needs to be called if Wait is not.
func (*Process) Signal ¶
Signal sends a signal to the running process. If this fails, for example if the process is not running, this will return an error.
func (*Process) StartAndWait ¶
StartAndWait starts the process and waits for it to exit
type SequentialProcesses ¶
type SequentialProcesses struct {
// contains filtered or unexported fields
}
func NewSequential ¶
func NewSequential(sequence ...*Process) (*SequentialProcesses, error)
NewSequential returns a newly generated SequentialProcesses structure with the provided processes
func (*SequentialProcesses) StartAndWait ¶
func (sq *SequentialProcesses) StartAndWait(ctx context.Context) error
StartAndWait sequentially starts the list of processes and waits for it to complete before starting the next.