Merge pull request #471 from nkirsch/tgid_support
Add support for parsing the tgid (thread group id) field.
This commit is contained in:
commit
49e4d328f8
|
@ -30,6 +30,8 @@ type Process struct {
|
|||
|
||||
lastCPUTimes *cpu.TimesStat
|
||||
lastCPUTime time.Time
|
||||
|
||||
tgid int32
|
||||
}
|
||||
|
||||
type OpenFilesStat struct {
|
||||
|
|
|
@ -83,6 +83,9 @@ func (p *Process) Name() (string, error) {
|
|||
|
||||
return common.IntToString(k.Proc.P_comm[:]), nil
|
||||
}
|
||||
func (p *Process) Tgid() (int32, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Exe() (string, error) {
|
||||
lsof_bin, err := exec.LookPath("lsof")
|
||||
if err != nil {
|
||||
|
|
|
@ -41,6 +41,9 @@ func (p *Process) Ppid() (int32, error) {
|
|||
func (p *Process) Name() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Tgid() (int32, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Exe() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
|
|
|
@ -50,6 +50,9 @@ func (p *Process) Name() (string, error) {
|
|||
|
||||
return common.IntToString(k.Comm[:]), nil
|
||||
}
|
||||
func (p *Process) Tgid() (int32, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Exe() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
|
|
|
@ -100,6 +100,16 @@ func (p *Process) Name() (string, error) {
|
|||
return p.name, nil
|
||||
}
|
||||
|
||||
// Tgid returns tgid, a Linux-synonym for user-space Pid
|
||||
func (p *Process) Tgid() (int32, error) {
|
||||
if p.tgid == 0 {
|
||||
if err := p.fillFromStatus(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return p.tgid, nil
|
||||
}
|
||||
|
||||
// Exe returns executable path of the process.
|
||||
func (p *Process) Exe() (string, error) {
|
||||
return p.fillFromExe()
|
||||
|
@ -820,6 +830,12 @@ func (p *Process) fillFromStatus() error {
|
|||
return err
|
||||
}
|
||||
p.parent = int32(pval)
|
||||
case "Tgid":
|
||||
pval, err := strconv.ParseInt(value, 10, 32)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.tgid = int32(pval)
|
||||
case "Uid":
|
||||
p.uids = make([]int32, 0, 4)
|
||||
for _, i := range strings.Split(value, "\t") {
|
||||
|
|
|
@ -53,6 +53,9 @@ func (p *Process) Name() (string, error) {
|
|||
|
||||
return common.IntToString(k.Comm[:]), nil
|
||||
}
|
||||
func (p *Process) Tgid() (int32, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Exe() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
|
|
|
@ -154,6 +154,10 @@ func (p *Process) Name() (string, error) {
|
|||
return name, nil
|
||||
}
|
||||
|
||||
func (p *Process) Tgid() (int32, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Exe() (string, error) {
|
||||
dst, err := GetWin32Proc(p.Pid)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue