Standard library / os/signal
os/signal.Stop()
Removes a channel from signal notifications and guarantees no more signals will be sent to it by this package after return. It does not close the channel. Example intended for Linux/AMD64 with Go 1.23.2 in a disposable working directory; other platforms may differ. Expected stdout: 'false\n'.
Formal Syntax & Structure
go syntaxgo
func Stop(c chan<- os.Signal)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| c | chan<- os.Signal | Channel used for signal delivery. |
Working Example
Example Snippetgo
package main
import ( "fmt" "os" "os/signal" "syscall")
func must(e error) { if e != nil { panic(e) }}func main() { c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGUSR1) signal.Stop(c) close(c) _, ok := <-c fmt.Println(ok)}