Merge pull request #25 from daddykotex/master

Ensure that interrupt signals are not relayed to the interrupt channel when the migration is over
This commit is contained in:
Matthias Kadenbach 2017-01-23 13:37:42 -08:00 committed by GitHub
commit 0b3426bf5d
1 changed files with 8 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package pipe
import (
"os"
"os/signal"
)
// New creates a new pipe. A pipe is basically a channel.
@ -25,6 +26,7 @@ func Close(pipe chan interface{}, err error) {
func WaitAndRedirect(pipe, redirectPipe chan interface{}, interrupt chan os.Signal) (ok bool) {
errorReceived := false
interruptsReceived := 0
defer stopNotifyInterruptChannel(interrupt)
if pipe != nil && redirectPipe != nil {
for {
select {
@ -75,3 +77,9 @@ func ReadErrors(pipe chan interface{}) []error {
}
return err
}
func stopNotifyInterruptChannel(interruptChannel chan os.Signal) {
if interruptChannel != nil {
signal.Stop(interruptChannel)
}
}