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
7package cgotest
8
9/*
10#cgo CFLAGS: -pthread
11#cgo LDFLAGS: -pthread
12extern int RunSigThread();
13extern int CheckBlocked();
14*/
15import "C"
16import (
17	"os"
18	"os/signal"
19	"syscall"
20	"testing"
21)
22
23var blocked bool
24
25//export IntoGoAndBack
26func IntoGoAndBack() {
27	// Verify that SIGIO stays blocked on the C thread
28	// even when unblocked for signal.Notify().
29	signal.Notify(make(chan os.Signal), syscall.SIGIO)
30	blocked = C.CheckBlocked() != 0
31}
32
33func testSigprocmask(t *testing.T) {
34	if r := C.RunSigThread(); r != 0 {
35		t.Errorf("pthread_create/pthread_join failed: %d", r)
36	}
37	if !blocked {
38		t.Error("Go runtime unblocked SIGIO")
39	}
40}
41