From 9c998f664a8f06f6b887ebcaad1e37cdbd1c4fcd Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Sun, 16 Jul 2017 08:13:49 -0700 Subject: [PATCH] Fix process.Exe() on macOS 10.12 The `lsof` command on macOS < 10.12 always selects the `p` field when using the `-F` option. On macOS 10.12 the `f` field is also always selected causing an incorrect result. This modification adds both options which are always selected to maintain consistency. --- process/process_darwin.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/process/process_darwin.go b/process/process_darwin.go index 9b4f574..63b64f6 100644 --- a/process/process_darwin.go +++ b/process/process_darwin.go @@ -99,8 +99,8 @@ func (p *Process) Exe() (string, error) { return "", err } - lsof := exec.Command(lsof_bin, "-p", strconv.Itoa(int(p.Pid)), "-Fn") - awk := exec.Command(awk_bin, "NR==3{print}") + lsof := exec.Command(lsof_bin, "-p", strconv.Itoa(int(p.Pid)), "-Fpfn") + awk := exec.Command(awk_bin, "NR==5{print}") sed := exec.Command(sed_bin, "s/n\\//\\//") output, _, err := common.Pipeline(lsof, awk, sed)