mirror of
https://github.com/golang/go
synced 2024-11-15 02:30:31 -07:00
6f59ccb052
https://golang.org/cl/10173 intrduced msigsave, ensureSigM and _SigUnblock but didn't enable the new signal save/restore mechanism for SIG{HUP,INT,QUIT,ABRT,TERM} on DragonFly BSD, FreeBSD and OpenBSD. At present, it looks like they have the implementation. This change enables the new mechanism on DragonFly BSD, FreeBSD and OpenBSD the same as Darwin, NetBSD. Change-Id: Ifb4b4743b3b4f50bfcdc7cf1fe1b59c377fa2a41 Reviewed-on: https://go-review.googlesource.com/18657 Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
39 lines
773 B
C
39 lines
773 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.
|
|
|
|
// +build !windows
|
|
|
|
#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);
|
|
}
|