Commit bd6601f4 authored by Andrew Gerrand's avatar Andrew Gerrand

os/signal: add Notify example

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/6615078
parent 4bee88d4
package signal_test
import (
"fmt"
"os"
"os/signal"
)
func ExampleNotify() {
// Set up channel on which to send signal notifications.
// We must use a buffered channel or risk missing the signal
// if we're not ready to receive when the signal is sent.
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill)
// Block until a signal is received.
s := <-c
fmt.Println("Got signal:", s)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment