mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-05 19:21:46 +00:00
Merge pull request #2316 from weaveworks/2315-empty-proc-cmdline
fall back to /proc/<pid>/comm for process name Fixes #2315
This commit is contained in:
@@ -112,7 +112,7 @@ func (w *walker) Walk(f func(Process, Process)) error {
|
||||
continue
|
||||
}
|
||||
|
||||
cmdline, name := "", "(unknown)"
|
||||
cmdline, name := "", ""
|
||||
if cmdlineBuf, err := cachedReadFile(path.Join(w.procRoot, filename, "cmdline")); err == nil {
|
||||
// like proc, treat name as the first element of command line
|
||||
i := bytes.IndexByte(cmdlineBuf, '\000')
|
||||
@@ -123,7 +123,13 @@ func (w *walker) Walk(f func(Process, Process)) error {
|
||||
cmdlineBuf = bytes.Replace(cmdlineBuf, []byte{'\000'}, []byte{' '}, -1)
|
||||
cmdline = string(cmdlineBuf)
|
||||
}
|
||||
|
||||
if name == "" {
|
||||
if commBuf, err := cachedReadFile(path.Join(w.procRoot, filename, "comm")); err == nil {
|
||||
name = "[" + strings.TrimSpace(string(commBuf)) + "]"
|
||||
} else {
|
||||
name = "(unknown)"
|
||||
}
|
||||
}
|
||||
f(Process{
|
||||
PID: pid,
|
||||
PPID: ppid,
|
||||
|
||||
Reference in New Issue
Block a user