go---process包

import "github.com/shirou/gopsutil/process"

是github上的一个项目(https://godoc.org/github.com/shirou/gopsutil/process#NewProcess),之所以用这个包是为了根据进程pid来获取到进程的开始执行时间。 

func NewProcess(pid int32) (*Process, error)
根据pid返回一个进程实例,下面的结构体就是返回的Process
type Process struct {
    Pid int32 `json:"pid"`
    name string
    status string
    parent int32
    numCtxSwitches *NumCtxSwitchesStat
    uids []int32
    gids []int32
    numThreads int32
    memInfo *MemoryInfoStat
    sigInfo *SignalInfoStat
    lastCPUTimes *cpu.TimesStat
    lastCPUTime time.Time
    tgid int32
}
func (p *Process) CreateTime() (int64, error)
返回该进程的创建时间,也就是进程的开始执行的时间,精确到毫秒。返回值是一个13位的时间戳

转载于:https://www.cnblogs.com/zhao1070285683/p/10390989.html

你可能感兴趣的:(go---process包)