...

Text file src/cmd/go/testdata/script/tool_signal_exit.txt

Documentation: cmd/go/testdata/script

     1[short] skip 'runs go build'
     2[GOOS:plan9] skip 'signals differ on Plan 9'
     3[GOOS:windows] skip 'os.Interrupt is not implemented on Windows'
     4
     5! go tool interrupter
     6stderr 'go tool interrupter: signal: interrupt'
     7
     8-- go.mod --
     9module example.com/interrupter
    10
    11go 1.26.0
    12
    13tool example.com/interrupter/cmd/interrupter
    14
    15-- cmd/interrupter/main.go --
    16package main
    17
    18import "os"
    19
    20func main() {
    21	p, err := os.FindProcess(os.Getpid())
    22	if err != nil {
    23		panic(err)
    24	}
    25	if err := p.Signal(os.Interrupt); err != nil {
    26		panic(err)
    27	}
    28	select {}
    29}

View as plain text