aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/os/signal/example_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/os/signal/example_test.go b/src/os/signal/example_test.go
index 5dfbe5f26b..ecefc757b4 100644
--- a/src/os/signal/example_test.go
+++ b/src/os/signal/example_test.go
@@ -21,3 +21,18 @@ func ExampleNotify() {
s := <-c
fmt.Println("Got signal:", s)
}
+
+func ExampleNotify_allSignals() {
+ // 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)
+
+ // Passing no signals to Notify means that
+ // all signals will be sent to the channel.
+ signal.Notify(c)
+
+ // Block until any signal is received.
+ s := <-c
+ fmt.Println("Got signal:", s)
+}