diff --git a/signal_stop_1.0.go b/signal_stop_1.0.go new file mode 100644 index 0000000..0ea0cd3 --- /dev/null +++ b/signal_stop_1.0.go @@ -0,0 +1,12 @@ +// +build !go1.1 + +package goworker + +import ( + "os" +) + +// Stops signals channel. This does not exist in +// Go less than 1.1. +func signalStop(c chan<- os.Signal) { +} diff --git a/signal_stop_1.1.go b/signal_stop_1.1.go new file mode 100644 index 0000000..11f6b9e --- /dev/null +++ b/signal_stop_1.1.go @@ -0,0 +1,14 @@ +// +build go1.1 + +package goworker + +import ( + "os" + "os/signal" +) + +// Stops signals channel. This function exists +// in Go greater or equal to 1.1. +func signalStop(c chan<- os.Signal) { + signal.Stop(c) +} diff --git a/signals.go b/signals.go index 35f5a66..95697cd 100644 --- a/signals.go +++ b/signals.go @@ -52,7 +52,7 @@ func signals() <-chan bool { defer close(signals) signal.Notify(signals, syscall.SIGQUIT, syscall.SIGTERM, os.Interrupt) - defer signal.Stop(signals) + defer signalStop(signals) <-signals quit <- true