[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.
pull/1231/head
shirou 4 years ago
parent 511da82e94
commit 35fbe38505

@ -351,11 +351,11 @@ func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, e
func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid)
if err != nil {
if len(pids) == 0 {
return nil, ErrorNoChildren
}
return nil, err
}
if len(pids) == 0 {
return nil, ErrorNoChildren
}
ret := make([]*Process, 0, len(pids))
for _, pid := range pids {
np, err := NewProcessWithContext(ctx, pid)

Loading…
Cancel
Save