Skip to content

Commit

Permalink
Don't use signal.Stop for Go less than 1.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
benmanns committed Sep 17, 2013
1 parent 8f5323e commit cbcee26
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
12 changes: 12 additions & 0 deletions signal_stop_1.0.go
Original file line number Diff line number Diff line change
@@ -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) {
}
14 changes: 14 additions & 0 deletions signal_stop_1.1.go
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 1 addition & 1 deletion signals.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cbcee26

Please sign in to comment.