Documentation ¶
Index ¶
- func GetExePathFromPid(pid int) (path string, err error)
- func GetPidCreateTime(pid ProcId) (time.Time, error)
- func GetProcCreateTime(procName string) (map[ProcId]time.Time, error)
- func Hide(pid ProcId) error
- func ReplaceMySelfFile(newfilepath string) error
- func RestartMyself() error
- func SelfDir() (string, error)
- func SelfPath() (string, error)
- func SelfShortName() (string, error)
- func Show(pid ProcId) error
- func Terminate(pid ProcId) error
- type ProcId
- type ProcInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetExePathFromPid ¶
func RestartMyself ¶
func RestartMyself() error
还可以参考:https://github.com/rcrowley/goagain/blob/master/goagain.go#L77 https://stackoverflow.com/questions/68201595/how-to-restart-itself-in-go-daemon-process Restart current process, with same parameters.
func SelfDir ¶
Notice: _, b, _, _ := runtime.Caller(0) return filepath.Dir(b) this is wrong
Get process file folder, not working folder
func SelfShortName ¶
SelfShortName returns last element of path - short filename.
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 GetPidByProcName ¶
func GetPidOfMyself ¶
func GetPidOfMyself() ProcId