Documentation ¶
Index ¶
- func FindPIDsWithMatchFn(matchFn MatchFn, log Log) ([]int, error)
- func FindProcesses(matcher Matcher, wait time.Duration, delay time.Duration, log Log) ([]ps.Process, error)
- func KillAll(matcher Matcher, log Log) (pids []int)
- func KillPID(pid int, log Log) error
- func TerminateAll(matcher Matcher, killDelay time.Duration, log Log) []int
- func TerminateAllWithProcessesFn(fn processesFn, matchFn MatchFn, killDelay time.Duration, log Log) (terminatedPids []int)
- func TerminatePID(pid int, killDelay time.Duration, log Log) error
- func WaitForExit(matcher Matcher, wait time.Duration, delay time.Duration, log Log) ([]ps.Process, error)
- type Log
- type MatchFn
- type MatchType
- type Matcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindPIDsWithMatchFn ¶
FindPIDsWithMatchFn returns pids for processes matching function
func FindProcesses ¶
func FindProcesses(matcher Matcher, wait time.Duration, delay time.Duration, log Log) ([]ps.Process, error)
FindProcesses returns processes containing string matching process path
func TerminateAll ¶
TerminateAll stops all processes with executable names that contains the matching string. It returns the pids that were terminated. This method only logs errors, if you need error handling, you can should use a different implementation.
func TerminateAllWithProcessesFn ¶
func TerminateAllWithProcessesFn(fn processesFn, matchFn MatchFn, killDelay time.Duration, log Log) (terminatedPids []int)
TerminateAllWithProcessesFn stops processes processesFn that satify the matchFn. It returns the pids that were terminated. This method only logs errors, if you need error handling, you can should use a different implementation.
func TerminatePID ¶
TerminatePID is an overly simple way to terminate a PID. On darwin and linux, it calls SIGTERM, then waits a killDelay and then calls SIGKILL. We don't mind if we call SIGKILL on an already terminated process, since there could be a race anyway where the process exits right after we check if it's still running but before the SIGKILL. The killDelay is not used on windows.
Types ¶
type Log ¶
type Log interface { Debugf(s string, args ...interface{}) Infof(s string, args ...interface{}) Warningf(s string, args ...interface{}) Errorf(s string, args ...interface{}) }
Log is the logging interface for the process package
type MatchType ¶
type MatchType string
MatchType is how to match
const ( // PathEqual matches path equals string PathEqual MatchType = "path-equal" // PathContains matches path contains string PathContains MatchType = "path-contains" // PathPrefix matches path has string prefix PathPrefix MatchType = "path-prefix" // ExecutableEqual matches executable name equals string ExecutableEqual MatchType = "executable-equal" )