Standard library / os/signal

os/signal.Ignore()

Requests that listed incoming signals be ignored. This alters process-wide handling; avoid in reusable libraries without coordination. Example intended for Linux/AMD64 with Go 1.23.2 in a disposable working directory; other platforms may differ. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func Ignore(sig ...os.Signal)

Parameters & Attributes

NameTypeDescription
sig...os.SignalSignal or list of signals, as indicated by the signature.

Working Example

Example Snippetgo
package main
import (  "fmt"  "os/signal"  "syscall")
func must(e error) {  if e != nil {    panic(e)  }}func main() {  signal.Ignore(syscall.SIGUSR1)  defer signal.Reset(syscall.SIGUSR1)  fmt.Println(signal.Ignored(syscall.SIGUSR1))}
Go Reference