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

     1  // Copyright 2026 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 !plan9
     6  
     7  package main
     8  
     9  import (
    10  	"os"
    11  	"os/signal"
    12  	"syscall"
    13  )
    14  
    15  func init() {
    16  	register("SignalBogus", SignalBogus)
    17  }
    18  
    19  // signal.Notify should effectively ignore bogus signal numbers. Never writing
    20  // to the channel, but otherwise allowing Notify/Stop as normal.
    21  //
    22  // This is a regression test for https://go.dev/issue/77076, where bogus
    23  // signals used to make Stop hang if there were no real signals installed.
    24  func SignalBogus() {
    25  	ch := make(chan os.Signal, 1)
    26  	signal.Notify(ch, syscall.Signal(0xdead))
    27  	signal.Stop(ch)
    28  	println("OK")
    29  }
    30  

View as plain text