mirror of
https://github.com/rwinkhart/rcw.git
synced 2026-10-28 22:48:16 -04:00
Add MacOS support
This commit is contained in:
1 parent
5369c3aa44
commit
107f4bcf02
3 files changed
+32
-7
No files matched your search
@@ -0,0 +1,18 @@
|
||||
//go:build darwin
|
||||
|
||||
package daemon
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// pidToPath returns the path of the executable that has the given PID.
|
||||
func pidToPath(pid int) string {
|
||||
pidString := strconv.Itoa(pid)
|
||||
cmd := exec.Command("lsof", "-a", "-dtxt", "-p"+pidString)
|
||||
output, _ := cmd.Output()
|
||||
line := strings.Split(string(output), "\n")[1]
|
||||
return line[strings.Index(line, "/"):]
|
||||
}
|
||||
Reference in new issue
Block a user