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>
17 int main(int argc
, char** argv
) {
22 printf("Missing argument\n");
31 printf("calling RunGoroutines\n");
39 printf("attempting segfault\n");
42 volatile int crash
= *(int *) 0;
50 printf("attempting external signal test\n");
53 fprintf(stderr
, "OK\n");
56 // The program should be interrupted before
57 // this sleep finishes. We use select rather
58 // than sleep because in older versions of
59 // glibc the sleep function does some signal
60 // fiddling to handle SIGCHLD. If this
61 // program is fiddling signals just when the
62 // test program sends the signal, the signal
63 // may be delivered to a Go thread which will
67 select(0, NULL
, NULL
, NULL
, &tv
);
73 printf("attempting SIGPIPE\n");
78 printf("pipe(2) failed\n");
81 // Close the reading end.
83 // Expect that write(2) fails (EPIPE)
84 if (write(fd
[1], "some data", 9) != -1) {
85 printf("write(2) unexpectedly succeeded\n");
90 printf("Unknown test: %d\n", test
);