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

Method AllProcs

proc.go:105–127  ·  view source on GitHub ↗

AllProcs returns a list of all currently available processes.

()

Source from the content-addressed store, hash-verified

103
104// AllProcs returns a list of all currently available processes.
105func (fs FS) AllProcs() (Procs, error) {
106 d, err := os.Open(fs.proc.Path())
107 if err != nil {
108 return Procs{}, err
109 }
110 defer d.Close()
111
112 names, err := d.Readdirnames(-1)
113 if err != nil {
114 return Procs{}, fmt.Errorf("%w: Cannot read file: %v: %w", ErrFileRead, names, err)
115 }
116
117 p := Procs{}
118 for _, n := range names {
119 pid, err := strconv.ParseInt(n, 10, 64)
120 if err != nil {
121 continue
122 }
123 p = append(p, Proc{PID: int(pid), fs: fs})
124 }
125
126 return p, nil
127}
128
129// CmdLine returns the command line of a process.
130func (p Proc) CmdLine() ([]string, error) {

Callers 2

AllProcsFunction · 0.95
TestAllProcsFunction · 0.80

Calls 1

PathMethod · 0.45

Tested by 1

TestAllProcsFunction · 0.64