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

     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
     6  stderr 'go tool interrupter: signal: interrupt'
     7  
     8  -- go.mod --
     9  module example.com/interrupter
    10  
    11  go 1.26.0
    12  
    13  tool example.com/interrupter/cmd/interrupter
    14  
    15  -- cmd/interrupter/main.go --
    16  package main
    17  
    18  import "os"
    19  
    20  func 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  }
    30  

View as plain text