t.Fatal(err)
}
- if out, err := exec.Command(bin[0], bin[1:]...).CombinedOutput(); err != nil {
+ darwin := "0"
+ if runtime.GOOS == "darwin" {
+ darwin = "1"
+ }
+ cmd = exec.Command(bin[0], append(bin[1:], darwin)...)
+
+ if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
}
t.Logf("%s", out)
expectSignal(t, err, syscall.SIGSEGV)
- // Test SIGPIPE forwarding
- cmd = exec.Command(bin[0], append(bin[1:], "3")...)
+ // SIGPIPE is never forwarded on darwin. See golang.org/issue/33384.
+ if runtime.GOOS != "darwin" {
+ // Test SIGPIPE forwarding
+ cmd = exec.Command(bin[0], append(bin[1:], "3")...)
- out, err = cmd.CombinedOutput()
- t.Logf("%s", out)
- expectSignal(t, err, syscall.SIGPIPE)
+ out, err = cmd.CombinedOutput()
+ t.Logf("%s", out)
+ expectSignal(t, err, syscall.SIGPIPE)
+ }
}
func TestSignalForwardingExternal(t *testing.T) {
}
defer os.Remove(exe)
- binArgs := append(cmdToRun(exe), "3")
+ binArgs := append(cmdToRun(exe), "1")
t.Log(binArgs)
out, err = exec.Command(binArgs[0], binArgs[1:]...).CombinedOutput()
t.Logf("%s", out)
- expectSignal(t, err, syscall.SIGPIPE)
+ expectSignal(t, err, syscall.SIGSEGV)
+
+ // SIGPIPE is never forwarded on darwin. See golang.org/issue/33384.
+ if runtime.GOOS != "darwin" {
+ binArgs := append(cmdToRun(exe), "3")
+ t.Log(binArgs)
+ out, err = exec.Command(binArgs[0], binArgs[1:]...).CombinedOutput()
+ t.Logf("%s", out)
+ expectSignal(t, err, syscall.SIGPIPE)
+ }
}
// Test that installing a second time recreates the header files.
sigset_t mask;
int i;
struct timespec ts;
+ int darwin;
+
+ darwin = atoi(argv[1]);
+
+ verbose = argc > 2;
- verbose = argc > 1;
setvbuf(stdout, NULL, _IONBF, 0);
// Call setsid so that we can use kill(0, SIGIO) below.
printf("provoking SIGPIPE\n");
}
- GoRaiseSIGPIPE();
+ // SIGPIPE is never forwarded on Darwin, see golang.org/issue/33384.
+ if (!darwin) {
+ GoRaiseSIGPIPE();
- if (verbose) {
- printf("waiting for sigpipeSeen\n");
- }
+ if (verbose) {
+ printf("waiting for sigpipeSeen\n");
+ }
- // Wait until the signal has been delivered.
- i = 0;
- while (!sigpipeSeen) {
- ts.tv_sec = 0;
- ts.tv_nsec = 1000000;
- nanosleep(&ts, NULL);
- i++;
- if (i > 5000) {
- fprintf(stderr, "looping too long waiting for SIGPIPE\n");
- exit(EXIT_FAILURE);
+ // Wait until the signal has been delivered.
+ i = 0;
+ while (!sigpipeSeen) {
+ ts.tv_sec = 0;
+ ts.tv_nsec = 1000000;
+ nanosleep(&ts, NULL);
+ i++;
+ if (i > 5000) {
+ fprintf(stderr, "looping too long waiting for SIGPIPE\n");
+ exit(EXIT_FAILURE);
+ }
}
}
#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");
}