signal

package
v0.0.0-...-1d03baa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2013 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package signal implements access to incoming signals.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Notify

func Notify(c chan<- os.Signal, sig ...os.Signal)

Notify causes package signal to relay incoming signals to c. If no signals are listed, all incoming signals will be relayed to c. Otherwise, just the listed signals will.

Package signal will not block sending to c: the caller must ensure that c has sufficient buffer space to keep up with the expected signal rate. For a channel used for notification of just one signal value, a buffer of size 1 is sufficient.

Example
package main

import (
	"fmt"
	"os"
	"os/signal"
)

func main() {
	// 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)
}
Output:

Types

This section is empty.

Notes

Bugs

  • This package is not yet implemented on Plan 9 and Windows.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL