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");
33 printf("calling RunGoroutines\n");
41 printf("attempting segfault\n");
52 printf("attempting external signal test\n");
55 fprintf(stderr, "OK\n");
58 // The program should be interrupted before
59 // this sleep finishes. We use select rather
60 // than sleep because in older versions of
61 // glibc the sleep function does some signal
62 // fiddling to handle SIGCHLD. If this
63 // program is fiddling signals just when the
64 // test program sends the signal, the signal
65 // may be delivered to a Go thread which will
69 select(0, NULL, NULL, NULL, &tv);
75 printf("attempting SIGPIPE\n");
80 printf("pipe(2) failed\n");
83 // Close the reading end.
85 // Expect that write(2) fails (EPIPE)
86 if (write(fd[1], "some data", 9) != -1) {
87 printf("write(2) unexpectedly succeeded\n");
90 printf("did not receive SIGPIPE\n");
94 printf("Unknown test: %d\n", test);