os/signal: add ability to ignore signals and restore initial signal handlers

There is currently no way to ignore signals using the os/signal package.
It is possible to catch a signal and do nothing but this is not the same
as ignoring it. The new function Ignore allows a set of signals to be
ignored. The new function Reset allows the initial handlers for a set of
signals to be restored.

Fixes #5572

Change-Id: I5c0f07956971e3a9ff9b9d9631e6e3a08c20df15
Reviewed-on: https://go-review.googlesource.com/3580
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Michael MacInnis 2015-01-29 22:37:41 -05:00 committed by Ian Lance Taylor
parent 10a4696fb8
commit 194ad16b83
12 changed files with 169 additions and 2 deletions

View file

@ -14,6 +14,7 @@ import (
// In assembly.
func signal_disable(uint32)
func signal_enable(uint32)
func signal_ignore(uint32)
func signal_recv() uint32
func loop() {
@ -51,3 +52,7 @@ func enableSignal(sig int) {
func disableSignal(sig int) {
signal_disable(uint32(sig))
}
func ignoreSignal(sig int) {
signal_ignore(uint32(sig))
}