Source file src/runtime/testdata/testprog/segv_linux.go

     1  // Copyright 2022 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  package main
     6  
     7  import "syscall"
     8  
     9  func init() {
    10  	register("TgkillSegv", TgkillSegv)
    11  }
    12  
    13  func TgkillSegv() {
    14  	c := make(chan bool)
    15  	go func() {
    16  		close(c)
    17  		for i := 0; ; i++ {
    18  			// Sum defined in segv.go.
    19  			Sum += i
    20  		}
    21  	}()
    22  
    23  	<-c
    24  
    25  	syscall.Tgkill(syscall.Getpid(), syscall.Gettid(), syscall.SIGSEGV)
    26  
    27  	// Wait for the OS to deliver the signal.
    28  	select {}
    29  }
    30  

View as plain text