diff --git a/unix/example_sysvshm_test.go b/unix/example_sysvshm_test.go index 8512eb59..537f7701 100644 --- a/unix/example_sysvshm_test.go +++ b/unix/example_sysvshm_test.go @@ -2,23 +2,18 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build (darwin && amd64) || linux -// +build darwin,amd64 linux +//go:build (darwin && amd64) || (linux && !android) +// +build darwin,amd64 linux,!android package unix_test import ( "log" - "runtime" "golang.org/x/sys/unix" ) func ExampleSysvShmGet() { - // sysv shared memory isn't implemented on Android - if runtime.GOOS == "android" { - return - } // create shared memory region of 1024 bytes id, err := unix.SysvShmGet(unix.IPC_PRIVATE, 1024, unix.IPC_CREAT|unix.IPC_EXCL|0o600) diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index 9a72fab6..fff38a84 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -2318,6 +2318,7 @@ type RemoteIovec struct { //sys PidfdOpen(pid int, flags int) (fd int, err error) = SYS_PIDFD_OPEN //sys PidfdGetfd(pidfd int, targetfd int, flags int) (fd int, err error) = SYS_PIDFD_GETFD + //sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error) //sys shmctl(id int, cmd int, buf *SysvShmDesc) (result int, err error) //sys shmdt(addr uintptr) (err error) diff --git a/unix/sysvshm_unix.go b/unix/sysvshm_unix.go index 9c92ffc7..7d6ba360 100644 --- a/unix/sysvshm_unix.go +++ b/unix/sysvshm_unix.go @@ -47,7 +47,7 @@ func SysvShmAttach(id int, addr uintptr, flag int) ([]byte, error) { // // It is not safe to use the slice after calling this function. func SysvShmDetach(data []byte) error { - if data == nil { + if len(data) == 0 { return EINVAL }