proc

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InitProcessID = 1
)

Variables

This section is empty.

Functions

func GetCommandNameBySocket

func GetCommandNameBySocket(network string, addr string, port uint16) (string, error)

func GetPidBySocket

func GetPidBySocket(network, addr string, port uint16) (int, error)

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

func GetPpidAndCommand(pid int) (int, string, error)

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

func GetProcessesBySocket

func GetProcessesBySocket(network string, addr string, port uint16) ([]string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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