gprocess

package
v0.0.0-...-04777cf Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KillByNamePattern

func KillByNamePattern(pattern string, killSelf bool) error

KillByNamePattern kills processes by name regex pattern. It returns an error if any occurred.

func KillByPID

func KillByPID(killSelf bool, pIDs ...string) error

Types

type CommandExecutor

type CommandExecutor interface {
	ExecuteCommand(stdout, stderr *bytes.Buffer, command string, args ...string) error
}

CommandExecutor is an interface to abstract command execution

type ProcessFilter

type ProcessFilter struct {
	Attrs           map[string]string
	CommandExecutor CommandExecutor
}

ProcessFilter represents a map-based configuration for filtering the list of processes.

func NewLiveProcessFilter

func NewLiveProcessFilter(attrs map[string]string) ProcessFilter

func (ProcessFilter) ListProcesses

func (pf ProcessFilter) ListProcesses() ([]map[string]string, error)

ListProcesses fetches and filters processes based on the underlying OS and the provided filter configuration. It returns a slice of maps, each representing a process, and an error if any occurred.

type RealCommandExecutor

type RealCommandExecutor struct{}

RealCommandExecutor is a real implementation of the CommandExecutor interface.

func (RealCommandExecutor) ExecuteCommand

func (e RealCommandExecutor) ExecuteCommand(stdout, stderr *bytes.Buffer, command string, args ...string) error

Jump to

Keyboard shortcuts

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