Chore: use unix.ByteSliceToString transform cstring
This commit is contained in:
parent
b6ff08074c
commit
c35cb24bda
1 changed files with 3 additions and 6 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue