|
|
@ -146,20 +146,18 @@ func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (p *Process) ParentWithContext(ctx context.Context) (*Process, error) {
|
|
|
|
func (p *Process) ParentWithContext(ctx context.Context) (*Process, error) {
|
|
|
|
rr, err := common.CallLsofWithContext(ctx, invoke, p.Pid, "-FR")
|
|
|
|
out, err := common.CallLsofWithContext(ctx, invoke, p.Pid, "-FR")
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, r := range rr {
|
|
|
|
for _, line := range out {
|
|
|
|
if strings.HasPrefix(r, "p") { // skip if process
|
|
|
|
if len(line) >= 1 && line[0] == 'R' {
|
|
|
|
continue
|
|
|
|
v, err := strconv.Atoi(line[1:])
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
l := string(r)
|
|
|
|
return nil, err
|
|
|
|
v, err := strconv.Atoi(strings.Replace(l, "R", "", 1))
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
return NewProcessWithContext(ctx, int32(v))
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NewProcessWithContext(ctx, int32(v))
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("could not find parent line")
|
|
|
|
return nil, fmt.Errorf("could not find parent line")
|
|
|
|
}
|
|
|
|
}
|
|
|
|