aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/testdata/testprogcgo/segv.go18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/runtime/testdata/testprogcgo/segv.go b/src/runtime/testdata/testprogcgo/segv.go
index 77e75f276a..3237a8c69c 100644
--- a/src/runtime/testdata/testprogcgo/segv.go
+++ b/src/runtime/testdata/testprogcgo/segv.go
@@ -10,8 +10,8 @@ package main
import "C"
import (
- "sync"
"syscall"
+ "time"
)
func init() {
@@ -23,12 +23,9 @@ var Sum int
func Segv() {
c := make(chan bool)
- var wg sync.WaitGroup
- wg.Add(1)
go func() {
- defer wg.Done()
close(c)
- for i := 0; i < 10000; i++ {
+ for i := 0; ; i++ {
Sum += i
}
}()
@@ -37,17 +34,15 @@ func Segv() {
syscall.Kill(syscall.Getpid(), syscall.SIGSEGV)
- wg.Wait()
+ // Give the OS time to deliver the signal.
+ time.Sleep(time.Second)
}
func SegvInCgo() {
c := make(chan bool)
- var wg sync.WaitGroup
- wg.Add(1)
go func() {
- defer wg.Done()
close(c)
- for i := 0; i < 10000; i++ {
+ for {
C.nop()
}
}()
@@ -56,5 +51,6 @@ func SegvInCgo() {
syscall.Kill(syscall.Getpid(), syscall.SIGSEGV)
- wg.Wait()
+ // Give the OS time to deliver the signal.
+ time.Sleep(time.Second)
}