首页 > 其他 > 详细

go---process包

时间:2019-02-17 14:21:44      阅读:257      评论:0      收藏:0      [点我收藏+]

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

是github上的一个项目,之所以用这个包是为了根据进程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位的时间戳

go---process包

原文:https://www.cnblogs.com/zhao1070285683/p/10390989.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!