mirror of
https://github.com/golang/go
synced 2024-11-23 12:00:14 -07:00
runtime: check sched_getaffinity return value
Android on ChromeOS uses a restrictive seccomp filter that blocks sched_getaffinity, leading this code to index a slice by -errno. Change-Id: Iec09a4f79dfbc17884e24f39bcfdad305de75b37 Reviewed-on: https://go-review.googlesource.com/34794 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
d698e614a2
commit
6a1cac2700
@ -91,6 +91,9 @@ func getproccount() int32 {
|
||||
const maxCPUs = 64 * 1024
|
||||
var buf [maxCPUs / (sys.PtrSize * 8)]uintptr
|
||||
r := sched_getaffinity(0, unsafe.Sizeof(buf), &buf[0])
|
||||
if r < 0 {
|
||||
return 1
|
||||
}
|
||||
n := int32(0)
|
||||
for _, v := range buf[:r/sys.PtrSize] {
|
||||
for v != 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user