MCPcopy Create free account
hub / github.com/prometheus/procfs / Self

Method Self

proc.go:77–87  ·  view source on GitHub ↗

Self returns a process for the current process.

()

Source from the content-addressed store, hash-verified

75
76// Self returns a process for the current process.
77func (fs FS) Self() (Proc, error) {
78 p, err := os.Readlink(fs.proc.Path("self"))
79 if err != nil {
80 return Proc{}, err
81 }
82 pid, err := strconv.Atoi(strings.ReplaceAll(p, string(fs.proc), ""))
83 if err != nil {
84 return Proc{}, err
85 }
86 return fs.Proc(pid)
87}
88
89// NewProc returns a process for the given pid.
90//

Callers 2

SelfFunction · 0.95
TestSelfFunction · 0.80

Calls 2

ProcMethod · 0.95
PathMethod · 0.45

Tested by 1

TestSelfFunction · 0.64