Skip to content

Commit

Permalink
Merge pull request #1661 from sthaha/fix-resolve-pid-0
Browse files Browse the repository at this point in the history
fix: resolve pid 0 to system_processes
  • Loading branch information
dave-tucker authored Aug 2, 2024
2 parents e74bfdd + cde7833 commit df3a4b6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/comm/resolve_comm.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"strconv"
"strings"

"github.com/sustainable-computing-io/kepler/pkg/utils"
"golang.org/x/sys/unix"
)

const unknownComm = "unknown"
const unknownComm = `unknown`

type CommResolver struct {
cacheExist map[int]string
Expand All @@ -35,6 +36,10 @@ func NewTestCommResolver(procFsResolver func(pid int) (string, error)) *CommReso
}

func (r *CommResolver) ResolveComm(pid int) (string, error) {
if pid == 0 {
return utils.SystemProcessName, nil
}

if comm, ok := r.cacheExist[pid]; ok {
return comm, nil
}
Expand Down

0 comments on commit df3a4b6

Please sign in to comment.