Skip to content

Commit 35fbe38

Browse files
committed
[process][linux] Fix error handling on Children.
If pgrep returns error, `CallPgrepWithContext` always returns empty pids. So this Children always returns ErrorNoChildren. This PR fixes that handling.
1 parent 511da82 commit 35fbe38

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

process/process_linux.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,11 @@ func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, e
351351
func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
352352
pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid)
353353
if err != nil {
354-
if len(pids) == 0 {
355-
return nil, ErrorNoChildren
356-
}
357354
return nil, err
358355
}
356+
if len(pids) == 0 {
357+
return nil, ErrorNoChildren
358+
}
359359
ret := make([]*Process, 0, len(pids))
360360
for _, pid := range pids {
361361
np, err := NewProcessWithContext(ctx, pid)

0 commit comments

Comments
 (0)