github.com/huandu/go@v0.0.0-20151114150818-04e615e41150/misc/cgo/test/sigprocmask_linux.c (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 #include <signal.h> 6 #include <stdlib.h> 7 #include <pthread.h> 8 #include <stdio.h> 9 #include <unistd.h> 10 11 extern void IntoGoAndBack(); 12 13 int CheckBlocked() { 14 sigset_t mask; 15 sigprocmask(SIG_BLOCK, NULL, &mask); 16 return sigismember(&mask, SIGIO); 17 } 18 19 static void* sigthreadfunc(void* unused) { 20 sigset_t mask; 21 sigemptyset(&mask); 22 sigaddset(&mask, SIGIO); 23 sigprocmask(SIG_BLOCK, &mask, NULL); 24 IntoGoAndBack(); 25 return NULL; 26 } 27 28 int RunSigThread() { 29 pthread_t thread; 30 int r; 31 32 r = pthread_create(&thread, NULL, &sigthreadfunc, NULL); 33 if (r != 0) 34 return r; 35 return pthread_join(thread, NULL); 36 }