mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
portlist: populate Pid field on Linux
The Port.Pid was always more of an implementation detail on some platforms and isn't necessary on Linux so it was never populated. (Nothing outside the portlist package ever used it) But might as well populate it for consistency since we have it in memory and its absence confused people. Updates #cleanup Change-Id: I869768a75c9fedeff242a5452206e2b2947a17cb Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
b29047bcf0
commit
52e4f24c58
@ -17,8 +17,8 @@
|
|||||||
type Port struct {
|
type Port struct {
|
||||||
Proto string // "tcp" or "udp"
|
Proto string // "tcp" or "udp"
|
||||||
Port uint16 // port number
|
Port uint16 // port number
|
||||||
Process string // optional process name, if found
|
Process string // optional process name, if found (requires suitable permissions)
|
||||||
Pid int // process id, if known
|
Pid int // process ID, if known (requires suitable permissions)
|
||||||
}
|
}
|
||||||
|
|
||||||
// List is a list of Ports.
|
// List is a list of Ports.
|
||||||
|
@ -322,6 +322,8 @@ func (li *linuxImpl) findProcessNames(need map[string]*portMeta) error {
|
|||||||
pe.pid = int(p)
|
pe.pid = int(p)
|
||||||
}
|
}
|
||||||
pe.port.Process = argvSubject(argv...)
|
pe.port.Process = argvSubject(argv...)
|
||||||
|
pid64, _ := mem.ParseInt(pid, 10, 0)
|
||||||
|
pe.port.Pid = int(pid64)
|
||||||
pe.needsProcName = false
|
pe.needsProcName = false
|
||||||
delete(need, string(targetBuf[:n]))
|
delete(need, string(targetBuf[:n]))
|
||||||
if len(need) == 0 {
|
if len(need) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user