Documentation ¶
Index ¶
- Constants
- func GetCommandNameBySocket(network string, addr string, port uint16) (string, error)
- func GetPidBySocket(network, addr string, port uint16) (int, error)
- func GetPpidAndCommand(pid int) (int, string, error)
- func GetProcessesBySocket(network string, addr string, port uint16) ([]string, error)
Constants ¶
View Source
const (
InitProcessID = 1
)
Variables ¶
This section is empty.
Functions ¶
func GetCommandNameBySocket ¶
func GetPidBySocket ¶
GetPidBySocket(network, addr string, port uint16) (int, error)
1. Read /proc/net/tcp/udp table according to network 2. Find socket inode number according to addr, port 3. Walk through /proc/[pid]/fd, find the matching inode and return the owning pid
func GetPpidAndCommand ¶
GetPpidAndCommand(pid int) (int, string, error)
1. Read /proc/[pid]/stat and scan for comm and ppid
Example: 555 (UVM global queu) S 2 0 0 0 -1 2129984 0 0 0 0 0 0 0 0 20 0 1 0 443 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 0 0 0 17 4 0 0 0 0 0 0 0 0 0 0 0 0 0
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.