Skip to content

Commit

Permalink
Merge pull request #1640 from MDrakos/fallback_ftxt
Browse files Browse the repository at this point in the history
Add fallback for lsof output
  • Loading branch information
shirou authored May 15, 2024
2 parents 3afb2ed + f4eca43 commit 8912445
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions process/process_darwin_nocgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@ func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
}
txtFound := 0
lines := strings.Split(string(out), "\n")
fallback := ""
for i := 1; i < len(lines); i++ {
if lines[i] == "ftxt" {
txtFound++
if txtFound == 1 {
fallback = lines[i-1][1:]
}
if txtFound == 2 {
return lines[i-1][1:], nil
}
}
}
if fallback != "" {
return fallback, nil
}
return "", fmt.Errorf("missing txt data returned by lsof")
}

Expand Down

0 comments on commit 8912445

Please sign in to comment.