gproc

package
v0.0.0-...-f3abbe6 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 10 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetExePathFromPid

func GetExePathFromPid(pid int) (path string, err error)

func GetPidCreateTime

func GetPidCreateTime(pid ProcId) (time.Time, error)

func GetProcCreateTime

func GetProcCreateTime(procName string) (map[ProcId]time.Time, error)

func Hide

func Hide(pid ProcId) error

隐藏进程,通过ps等命令看不到进程信息, 一般是通过把pid改为0做到的,windows下应该有api

func ReplaceMySelfFile

func ReplaceMySelfFile(newfilepath string) error

替换自己的二进制文件

func RestartMyself

func RestartMyself() error

还可以参考:https://github.com/rcrowley/goagain/blob/master/goagain.go#L77 Restart current process, with same parameters.

func SelfBase

func SelfBase() (string, error)

returns last element of path: short filename

func SelfDir

func SelfDir() (string, error)

Notice: _, b, _, _ := runtime.Caller(0) return filepath.Dir(b) this is wrong

Get process file folder, not working folder

func SelfPath

func SelfPath() (string, error)

func Show

func Show(pid ProcId) error

func Terminate

func Terminate(pid ProcId) error

Types

type ProcId

type ProcId int32

on linux 32768 by default, you can read the value on your system in /proc/sys/kernel/pid_max, and you can set the value higher (up to 32768 for 32 bit systems or 4194304 for 64 bit) with: echo 4194303 > /proc/sys/kernel/pid_max on windows process id is a DWORD value, so max id value is int32 max value 4294967295

const (
	InvalidProcId ProcId = -1
)

func GetAllPids

func GetAllPids() ([]ProcId, error)

func GetPidByProcFullFilename

func GetPidByProcFullFilename(filename string) ([]ProcId, error)

func GetPidByProcName

func GetPidByProcName(procName string) ([]ProcId, error)

func GetPidOfMyself

func GetPidOfMyself() ProcId

type ProcInfo

type ProcInfo struct {
	Name         string // short filename
	Filename     string // full file path
	Cmdline      string // run command line
	Param        string // run param
	MemUsedBytes uint64
}

func GetProcInfo

func GetProcInfo(pid ProcId) (*ProcInfo, error)

Jump to

Keyboard shortcuts

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