proc

package
v2.14.3-rc.5 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const SIGTERM = unix.SIGTERM

Variables

View Source
var CommandContext = dexec.CommandContext //nolint:gochecknoglobals // OS-specific function replacement
View Source
var SignalsToForward = []os.Signal{unix.SIGINT, unix.SIGTERM} //nolint:gochecknoglobals // OS-specific constant list

Functions

func CacheAdmin added in v2.14.3

func CacheAdmin(ctx context.Context, prompt string) error

CacheAdmin will ensure that the current process is able to invoke subprocesses with admin rights without having to ask for the password again. This is needed among other things to make sure the integration tests can see that a password is being asked for.

func CaptureErr added in v2.13.0

func CaptureErr(ctx context.Context, cmd *dexec.Cmd) ([]byte, error)

CaptureErr disables command logging, captures Stdout and Stderr to two different buffers. If an error occurs, the stdout output is discarded and the stderr output is included in the returned error unless the error itself already contains that output. On success, any output on stderr is discarded and the stdout output is returned.

func CreateNewProcessGroup added in v2.14.0

func CreateNewProcessGroup(cmd *dexec.Cmd)

CreateNewProcessGroup ensures that the process uses a process group of its own to prevent it getting affected by <ctrl-c> in the terminal.

func IsAdmin

func IsAdmin() bool

func KillProcessGroup added in v2.14.0

func KillProcessGroup(ctx context.Context, cmd *exec.Cmd, signal os.Signal)

func Run

func Run(ctx context.Context, env map[string]string, exe string, args ...string) error

Run will run the given executable with given args and env, wait for it to terminate, and return the result. The run will dispatch signals as appropriate for the given platform (SIGTERM and SIGINT on Unix platforms and os.Interrupt on Windows).

func RunningInContainer added in v2.12.0

func RunningInContainer() bool

RunningInContainer returns true if the current process runs from inside a docker container.

func Start added in v2.6.0

func Start(ctx context.Context, env map[string]string, exe string, args ...string) (*dexec.Cmd, error)

Start will start the given executable with given args and env, and return the command. The signals are dispatched as appropriate for the given platform (SIGTERM and SIGINT on Unix platforms and os.Interrupt on Windows).

func StartInBackground

func StartInBackground(includeEnv bool, args ...string) error

func StartInBackgroundAsRoot

func StartInBackgroundAsRoot(ctx context.Context, args ...string) error

func StdCommand added in v2.12.0

func StdCommand(ctx context.Context, exe string, args ...string) *dexec.Cmd

StdCommand returns a command that redirects stdout and stderr to dos.Stdout and dos.Stderr and performs no logging.

func Terminate added in v2.7.3

func Terminate(p *os.Process) error

func Wait added in v2.6.0

func Wait(ctx context.Context, cancel context.CancelFunc, cmd *dexec.Cmd) error

Wait will wait for the Process of the command to finish. If cancel is not nil, Wait will listen for os signals and call cancel when it receives one.

Types

This section is empty.

Jump to

Keyboard shortcuts

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