Skip to content

Commit 8912445

Browse files
authored
Merge pull request #1640 from MDrakos/fallback_ftxt
Add fallback for lsof output
2 parents 3afb2ed + f4eca43 commit 8912445

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

process/process_darwin_nocgo.go

+7
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,21 @@ func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
2424
}
2525
txtFound := 0
2626
lines := strings.Split(string(out), "\n")
27+
fallback := ""
2728
for i := 1; i < len(lines); i++ {
2829
if lines[i] == "ftxt" {
2930
txtFound++
31+
if txtFound == 1 {
32+
fallback = lines[i-1][1:]
33+
}
3034
if txtFound == 2 {
3135
return lines[i-1][1:], nil
3236
}
3337
}
3438
}
39+
if fallback != "" {
40+
return fallback, nil
41+
}
3542
return "", fmt.Errorf("missing txt data returned by lsof")
3643
}
3744

0 commit comments

Comments
 (0)