|
|
|
@ -153,7 +153,7 @@ func parseSocktab(r io.Reader, accept AcceptFn) ([]SockTabEntry, error) { |
|
|
|
|
} |
|
|
|
|
e.UID = uint32(u) |
|
|
|
|
e.ino = fields[9] |
|
|
|
|
extractProcInfo(&e) |
|
|
|
|
extractProcInfo(&e) |
|
|
|
|
if accept(&e) { |
|
|
|
|
tab = append(tab, e) |
|
|
|
|
} |
|
|
|
@ -201,29 +201,29 @@ func (p *procFd) iterFdDir() { |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sk := p.sktab |
|
|
|
|
ss := sockPrefix + sk.ino + "]" |
|
|
|
|
if ss != lname { |
|
|
|
|
continue |
|
|
|
|
sk := p.sktab |
|
|
|
|
ss := sockPrefix + sk.ino + "]" |
|
|
|
|
if ss != lname { |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
if p.p == nil { |
|
|
|
|
stat, err := os.Open(path.Join(p.base, "stat")) |
|
|
|
|
if err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if p.p == nil { |
|
|
|
|
stat, err := os.Open(path.Join(p.base, "stat")) |
|
|
|
|
if err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if stat != nil { |
|
|
|
|
defer stat.Close() |
|
|
|
|
} |
|
|
|
|
n, err := stat.Read(buf[:]) |
|
|
|
|
if err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
z := bytes.SplitN(buf[:n], []byte(" "), 3) |
|
|
|
|
name := getProcName(z[1]) |
|
|
|
|
p.p = &Process{p.pid, name} |
|
|
|
|
stat.Close() |
|
|
|
|
if stat != nil { |
|
|
|
|
defer stat.Close() |
|
|
|
|
} |
|
|
|
|
sk.Process = p.p |
|
|
|
|
n, err := stat.Read(buf[:]) |
|
|
|
|
if err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
z := bytes.SplitN(buf[:n], []byte(" "), 3) |
|
|
|
|
name := getProcName(z[1]) |
|
|
|
|
p.p = &Process{p.pid, name} |
|
|
|
|
stat.Close() |
|
|
|
|
} |
|
|
|
|
sk.Process = p.p |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -262,7 +262,11 @@ func doNetstat(path string, fn AcceptFn) ([]SockTabEntry, error) { |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
//extractProcInfo(tabs)
|
|
|
|
|
|
|
|
|
|
if len(tabs) != 0 { |
|
|
|
|
extractProcInfo(tabs) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return tabs, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|