From 8a695e82cd0d88704e282e6f8def6fbfd5f724c4 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Fri, 26 Jul 2013 17:40:45 -0700 Subject: [PATCH] Exit from `docker login` on SIGTERM and SIGINT. Fixes #1299. Upstream-commit: 01ce312c2d3e56a7993f7d644675513e1acca17c Component: engine --- components/engine/commands.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/engine/commands.go b/components/engine/commands.go index 0fabaa385f..1fb56e98a6 100644 --- a/components/engine/commands.go +++ b/components/engine/commands.go @@ -319,6 +319,14 @@ func (cli *DockerCli) CmdLogin(args ...string) error { authconfig = auth.AuthConfig{} } + c := make(chan os.Signal, 1) + signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) + go func() { + for sig := range c { + os.Exit(1) + } + }() + if *flUsername == "" { fmt.Fprintf(cli.out, "Username (%s): ", authconfig.Username) username = readAndEchoString(cli.in, cli.out)