1// Copyright 2020 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5//go:build unix 6 7package main 8 9import "syscall" 10 11func init() { 12 register("Segv", Segv) 13} 14 15var Sum int 16 17func Segv() { 18 c := make(chan bool) 19 go func() { 20 close(c) 21 for i := 0; ; i++ { 22 Sum += i 23 } 24 }() 25 26 <-c 27 28 syscall.Kill(syscall.Getpid(), syscall.SIGSEGV) 29 30 // Wait for the OS to deliver the signal. 31 select {} 32} 33