1
0
mirror of https://github.com/golang/go synced 2024-11-18 06:14:46 -07:00
go/misc/cgo/test/sigprocmask_linux.c
Elias Naur 22e4b8167f misc/cgo/test: fix build for CC=clang
Fix build error when CL=clang introduced by CL 10173.

Change-Id: I8edf210787a9803280c0779ff710c7e634a820d6
Reviewed-on: https://go-review.googlesource.com/10341
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-05-22 22:54:24 +00:00

37 lines
753 B
C

// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include <signal.h>
#include <stdlib.h>
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
extern void IntoGoAndBack();
int CheckBlocked() {
sigset_t mask;
sigprocmask(SIG_BLOCK, NULL, &mask);
return sigismember(&mask, SIGIO);
}
static void* sigthreadfunc(void* unused) {
sigset_t mask;
sigemptyset(&mask);
sigaddset(&mask, SIGIO);
sigprocmask(SIG_BLOCK, &mask, NULL);
IntoGoAndBack();
return NULL;
}
int RunSigThread() {
pthread_t thread;
int r;
r = pthread_create(&thread, NULL, &sigthreadfunc, NULL);
if (r != 0)
return r;
return pthread_join(thread, NULL);
}