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.
21 static void sigsegv() {
23 fprintf(stderr, "ERROR: C SIGSEGV not thrown on caught?.\n");
27 static void segvhandler(int signum) {
28 if (signum == SIGSEGV) {
29 fprintf(stdout, "OK\n");
34 static void __attribute__ ((constructor)) sigsetup(void) {
35 if (getenv("GO_TEST_CGOSIGFWD") == NULL) {
41 memset(&act, 0, sizeof act);
42 act.sa_handler = segvhandler;
43 sigaction(SIGSEGV, &act, NULL);
49 register("CgoSigfwd", CgoSigfwd)
57 fmt.Errorf("ERROR: couldn't raise SIGSEGV in Go.")
67 if os.Getenv("GO_TEST_CGOSIGFWD") == "" {
68 fmt.Fprintf(os.Stderr, "test must be run with GO_TEST_CGOSIGFWD set\n")
72 // Test that the signal originating in Go is handled (and recovered) by Go.
74 fmt.Fprintf(os.Stderr, "couldn't recover from SIGSEGV in Go.\n")
78 // Test that the signal originating in C is handled by C.