예제 #1
0
        public static void CgoExternalThreadSignal()
        {
            if (len(os.Args) > 2L && os.Args[2L] == "crash")
            {
                var i = C.start_crashing_thread();
                if (i != 0L)
                {
                    fmt.Println("pthread_create failed:", i);
                    // Exit with 0 because parent expects us to crash.
                    return;
                }

                // We should crash immediately, but give it plenty of
                // time before failing (by exiting 0) in case we are
                // running on a slow system.
                time.Sleep(5L * time.Second);
                return;
            }

            var(out, err) = exec.Command(os.Args[0L], "CgoExternalThreadSignal", "crash").CombinedOutput();
            if (err == null)
            {
                fmt.Println("C signal did not crash as expected");
                fmt.Printf("\n%s\n", out);
                os.Exit(1L);
            }

            fmt.Println("OK");
        }