Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KillProcess ¶
func KillProcessByPort ¶
KillProcessByPort kills every process bound to the port. With tree=true, each process is killed together with all of its descendants.
func KillProcessTree ¶ added in v1.1.0
KillProcessTree kills a process and all of its descendants. Descendants are discovered from a single snapshot taken before the first kill, and the root is killed first so it cannot spawn replacements for already-killed children. A descendant that exited before its turn is skipped; its PID is simply absent from the returned list. Only a failure to kill the root is an error.
Types ¶
type PortInfo ¶
type PortInfo struct {
Protocol string // "TCP" or "UDP"
LocalAddr string
LocalPort uint16
RemoteAddr string // empty for UDP (connectionless)
RemotePort uint16
PID uint32
State string // empty for UDP
}
func FindProcessByPort ¶
FindProcessByPort scans TCP and UDP tables over IPv4 and IPv6. A family that fails is skipped as long as at least one family succeeds.
type ProcessDetails ¶ added in v1.1.0
type ProcessDetails struct {
PID uint32
Name string
ParentPID uint32
ThreadCount uint32
ExecutablePath string // empty when access is denied
CommandLine string // empty when unavailable (access denied or system process)
WorkingSetBytes uint64 // 0 when unavailable
PrivateBytes uint64 // 0 when unavailable
}
func GetProcessInfo ¶ added in v1.1.0
func GetProcessInfo(pid uint32) (*ProcessDetails, error)
GetProcessInfo returns details for one process. Name, parent PID, and thread count always come from the process snapshot; path, command line, and memory usage are best-effort and stay zero-valued when the process cannot be opened (e.g. protected system processes).
type ProcessInfo ¶
func ListProcesses ¶
func ListProcesses(filter string) ([]ProcessInfo, error)