Since we're sleeping rather than waiting for the goroutines,
let the goroutines run forever.
Fixes #38595
Change-Id: I4cd611fd7565f6e8d91e50c9273d91c514825314
Reviewed-on: https://go-review.googlesource.com/c/go/+/229484
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
import "C"
import (
- "sync"
"syscall"
+ "time"
)
func init() {
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
}
}()
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()
}
}()
syscall.Kill(syscall.Getpid(), syscall.SIGSEGV)
- wg.Wait()
+ // Give the OS time to deliver the signal.
+ time.Sleep(time.Second)
}