exec

package
v0.9.4-4-g3d8a6389 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: BSD-3-Clause Imports: 9 Imported by: 2

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.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseInterfaceArgs

func ParseInterfaceArgs(face interface{}, args ...string) ([]string, error)

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) Cmd added in v0.6.0

func (e *Process) Cmd() *exec.Cmd

Cmd returns the go Cmd of the process.

func (*Process) Cmdline

func (e *Process) Cmdline() string

Cmdline returns the full command line to be executed

func (*Process) Kill

func (e *Process) Kill() error

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

func (e *Process) Pid() (int, error)

Pid returns the process ID

func (*Process) Release added in v0.6.0

func (e *Process) Release() error

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

func (e *Process) Signal(signal syscall.Signal) error

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

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

Start the process

func (*Process) StartAndWait

func (e *Process) StartAndWait(ctx context.Context) error

StartAndWait starts the process and waits for it to exit

func (*Process) Wait

func (e *Process) Wait() error

Wait for the process to complete

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.

Jump to

Keyboard shortcuts

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