Documentation
¶
Overview ¶
Package process provides the definition of a Process and a process Builder.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder interface {
// SetSimExePath sets the "simulated" executable path. This sets the executable path accessible through
// `readlink -f /proc/<pid/exepath` for the started process. The underlying implementation ensures the existence of
// each segment of the provided path, by possibly creating some of them. Path segments contextually created are
// automatically removed after the process resources are released. If unset or empty, it is randomly generated.
SetSimExePath(simExePath string)
// SetName is the process name. If unset or empty, it defaults to filepath.Base(SimExePath).
SetName(name string)
// SetArg0 sets the argument in position 0 (a.k.a. argv[0]) of the process. If unset or empty, it defaults to the
// process name if this is not empty; otherwise, it defaults to filepath.Base(SimExePath).
SetArg0(arg0 string)
// SetArgs sets the process arguments. It accepts a string containing the space-separated list of command line
// arguments. If a single argument contains spaces, the entire argument must be quoted in order to not be considered
// as multiple arguments.
SetArgs(args string)
// SetEnv sets the list of environment variables that must be provided to the process.
SetEnv(env []string)
// SetUsername sets the name of the user that must run the process. If unset or empty, the current process user is
// used. If the specified user does not exist, it is created before running the test and deleted after test
// execution.
SetUsername(username string)
// SetCapabilities sets the capabilities that must be set on the process executable file. The syntax follows the
// conventions specified by cap_from_text(3). If unset or empty, it defaults to 'all=iep'.
SetCapabilities(capabilities string)
// Build builds the process, setting the logger managing its lifecycle and the command that it is going to run.
// The provided context can be used at any time to cancel the process execution after it is started.
// After calling Build, the Builder process-related configuration is cleared and the Builder can be reused to build
// another process.
Build(ctx context.Context, logger logr.Logger, command string) Process
}
Builder allows to build a new process.
type Process ¶
type Process interface {
// Start starts the process.
Start() error
// Wait waits for process to exit and releases the related resources.
Wait() error
// Kill kills the process and releases the related resources.
Kill() error
// PID returns the process identifier.
PID() int
}
Process represents a runnable process.
Click to show internal directories.
Click to hide internal directories.