Home | History | Annotate | Download | only in signal
      1 // Copyright 2013 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 package signal_test
      6 
      7 import (
      8 	"fmt"
      9 	"os"
     10 	"os/signal"
     11 )
     12 
     13 func ExampleNotify() {
     14 	// Set up channel on which to send signal notifications.
     15 	// We must use a buffered channel or risk missing the signal
     16 	// if we're not ready to receive when the signal is sent.
     17 	c := make(chan os.Signal, 1)
     18 	signal.Notify(c, os.Interrupt)
     19 
     20 	// Block until a signal is received.
     21 	s := <-c
     22 	fmt.Println("Got signal:", s)
     23 }
     24