summaryrefslogtreecommitdiffstats
path: root/src/runtime/testdata/testprog/segv_linux.go
blob: aa386bbf255b7f08b5378a6c9795be022a764768 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import "syscall"

func init() {
	register("TgkillSegv", TgkillSegv)
}

func TgkillSegv() {
	c := make(chan bool)
	go func() {
		close(c)
		for i := 0; ; i++ {
			// Sum defined in segv.go.
			Sum += i
		}
	}()

	<-c

	syscall.Tgkill(syscall.Getpid(), syscall.Gettid(), syscall.SIGSEGV)

	// Wait for the OS to deliver the signal.
	select {}
}