#include <time.h>
#include <sched.h>
#include <unistd.h>
-#include <pthread.h>
#include "libgo3.h"
}
}
-static void *provokeSIGPIPE(void *arg) {
- ProvokeSIGPIPE();
- return NULL;
-}
-
int main(int argc, char** argv) {
int verbose;
struct sigaction sa;
int i;
struct timespec ts;
- int res;
- pthread_t tid;
verbose = argc > 2;
setvbuf(stdout, NULL, _IONBF, 0);
// a non-default SIGPIPE handler before the runtime initializes.
ProvokeSIGPIPE();
- // Test that SIGPIPE on a non-main thread is also handled by Go.
- res = pthread_create(&tid, NULL, provokeSIGPIPE, NULL);
- if (res != 0) {
- fprintf(stderr, "pthread_create: %s\n", strerror(res));
- exit(EXIT_FAILURE);
- }
-
- res = pthread_join(tid, NULL);
- if (res != 0) {
- fprintf(stderr, "pthread_join: %s\n", strerror(res));
- exit(EXIT_FAILURE);
- }
-
if (verbose) {
printf("calling sigaction\n");
}
return true
}
- // This function and its caller sigtrampgo assumes SIGPIPE is delivered on the
- // originating thread. This property does not hold on macOS (golang.org/issue/33384),
- // so we have no choice but to ignore SIGPIPE.
- if GOOS == "darwin" && sig == _SIGPIPE {
- return true
- }
-
// If there is no handler to forward to, no need to forward.
if fwdFn == _SIG_DFL {
return false