github.com/kidsbmilk/gofrontend_all@v0.0.0-20220701224323-6479d5976c5d/libgo/misc/cgo/test/sigprocmask.go (about) 1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build !windows 6 // +build !windows 7 8 package cgotest 9 10 /* 11 #cgo CFLAGS: -pthread 12 #cgo LDFLAGS: -pthread 13 extern int RunSigThread(); 14 extern int CheckBlocked(); 15 */ 16 import "C" 17 import ( 18 "os" 19 "os/signal" 20 "syscall" 21 "testing" 22 ) 23 24 var blocked bool 25 26 //export IntoGoAndBack 27 func IntoGoAndBack() { 28 // Verify that SIGIO stays blocked on the C thread 29 // even when unblocked for signal.Notify(). 30 signal.Notify(make(chan os.Signal), syscall.SIGIO) 31 blocked = C.CheckBlocked() != 0 32 } 33 34 func testSigprocmask(t *testing.T) { 35 if r := C.RunSigThread(); r != 0 { 36 t.Errorf("pthread_create/pthread_join failed: %d", r) 37 } 38 if !blocked { 39 t.Error("Go runtime unblocked SIGIO") 40 } 41 }