Close tty on exit (#7411)

This commit is contained in:
Adrien Delorme 2019-03-15 11:10:30 +01:00 committed by GitHub
parent 4e76f51462
commit 513999b8e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 0 deletions

View File

@ -192,6 +192,8 @@ func wrappedMain() int {
TTY, err = tty.Open()
if err != nil {
fmt.Fprintf(os.Stderr, "No tty available: %s\n", err)
} else {
defer TTY.Close()
}
}
ui = &packer.BasicUi{

View File

@ -2,4 +2,5 @@ package packer
type TTY interface {
ReadString() (string, error)
Close() error
}

View File

@ -42,6 +42,7 @@ type testTTY struct {
say string
}
func (tty *testTTY) Close() error { return nil }
func (tty *testTTY) ReadString() (string, error) {
return tty.say, nil
}