command/push: ctrl-C should work properly

This commit is contained in:
Mitchell Hashimoto 2014-12-03 14:15:48 -06:00
parent cc61a7dfb8
commit 80c93bfea0

View File

@ -4,6 +4,8 @@ import (
"flag"
"fmt"
"io"
"os"
"os/signal"
"path/filepath"
"strings"
@ -188,10 +190,17 @@ func (c *PushCommand) Run(args []string) int {
return 1
}
// Make a ctrl-C channel
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, os.Interrupt)
defer signal.Stop(sigCh)
err = nil
select {
case err = <-uploadErrCh:
err = fmt.Errorf("Error uploading: %s", err)
case <-sigCh:
err = fmt.Errorf("Push cancelled from Ctrl-C")
case <-doneCh:
}