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.
5 // Test for verifying that the Go runtime properly forwards
6 // signals when non-Go signals are raised.
11 #include <sys/types.h>
13 #include <sys/select.h>
19 int main(int argc, char** argv) {
24 printf("Missing argument\n");
37 printf("attempting segfault\n");
48 printf("attempting external signal test\n");
51 fprintf(stderr, "OK\n");
54 // The program should be interrupted before
55 // this sleep finishes. We use select rather
56 // than sleep because in older versions of
57 // glibc the sleep function does some signal
58 // fiddling to handle SIGCHLD. If this
59 // program is fiddling signals just when the
60 // test program sends the signal, the signal
61 // may be delivered to a Go thread which will
65 select(0, NULL, NULL, NULL, &tv);
71 printf("attempting SIGPIPE\n");
76 printf("pipe(2) failed\n");
79 // Close the reading end.
81 // Expect that write(2) fails (EPIPE)
82 if (write(fd[1], "some data", 9) != -1) {
83 printf("write(2) unexpectedly succeeded\n");
86 printf("did not receive SIGPIPE\n");
90 fprintf(stderr, "OK\n");
94 printf("calling Block\n");
99 printf("Unknown test: %d\n", test);