diff --git a/component/process/process_darwin.go b/component/process/process_darwin.go index 5157b209..7e4baf74 100644 --- a/component/process/process_darwin.go +++ b/component/process/process_darwin.go @@ -1,12 +1,13 @@ package process import ( - "bytes" "encoding/binary" "net" "path/filepath" "syscall" "unsafe" + + "golang.org/x/sys/unix" ) const ( @@ -94,12 +95,8 @@ func getExecPathFromPID(pid uint32) (string, error) { if errno != 0 { return "", errno } - firstZero := bytes.IndexByte(buf, 0) - if firstZero <= 0 { - return "", nil - } - return filepath.Base(string(buf[:firstZero])), nil + return filepath.Base(unix.ByteSliceToString(buf)), nil } func readNativeUint32(b []byte) uint32 {