mirror of https://github.com/status-im/migrate.git
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:
commit
0b3426bf5d
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue