@@ -15,7 +15,6 @@ import (
15
15
"testing"
16
16
"time"
17
17
18
- gops "github.com/mitchellh/go-ps"
19
18
"github.com/shirou/gopsutil/v4/process"
20
19
"github.com/stretchr/testify/require"
21
20
@@ -251,33 +250,41 @@ func countGoLines(tb testing.TB) int {
251
250
func getLinterMemoryMB (tb testing.TB ) (int , error ) {
252
251
tb .Helper ()
253
252
254
- processes , err := gops .Processes ()
253
+ processes , err := process .Processes ()
255
254
if err != nil {
256
255
tb .Fatalf ("can't get processes: %s" , err )
257
256
}
258
257
259
- var progPID int
258
+ var progPID int32
260
259
for _ , p := range processes {
260
+ exe , err := p .Exe ()
261
+ if err != nil {
262
+ continue
263
+ }
261
264
// The executable name can be shorter than the binary name.
262
- if strings .HasPrefix (binName , p . Executable ( )) {
263
- progPID = p .Pid ()
265
+ if strings .HasPrefix (binName , filepath . Base ( exe )) {
266
+ progPID = p .Pid
264
267
break
265
268
}
266
269
}
267
270
if progPID == 0 {
268
271
return 0 , errors .New ("no process" )
269
272
}
270
273
271
- allProgPIDs := []int {progPID }
274
+ allProgPIDs := []int32 {progPID }
272
275
for _ , p := range processes {
273
- if p .PPid () == progPID {
274
- allProgPIDs = append (allProgPIDs , p .Pid ())
276
+ ppid , err := p .Ppid ()
277
+ if err != nil {
278
+ continue
279
+ }
280
+ if ppid == progPID {
281
+ allProgPIDs = append (allProgPIDs , p .Pid )
275
282
}
276
283
}
277
284
278
285
var totalProgMemBytes uint64
279
286
for _ , pid := range allProgPIDs {
280
- p , err := process .NewProcess (int32 ( pid ) )
287
+ p , err := process .NewProcess (pid )
281
288
if err != nil {
282
289
continue // subprocess could die
283
290
}
0 commit comments