helper/password: interrupt should exit readline

This commit is contained in:
Mitchell Hashimoto 2015-10-16 16:00:34 -07:00
parent e6f96f71da
commit 2917e6be2f

View file

@ -50,6 +50,13 @@ func readline(f *os.File) (string, error) {
break
}
// ASCII code 3 is what is sent for a Ctrl-C while reading raw.
// If we see that, then get the interrupt. We have to do this here
// because terminals in raw mode won't catch it at the shell level.
if buf[0] == 3 {
return "", ErrInterrupted
}
resultBuf = append(resultBuf, buf[0])
}