Close tty on exit (#7411)
This commit is contained in:
parent
4e76f51462
commit
513999b8e7
2
main.go
2
main.go
|
@ -192,6 +192,8 @@ func wrappedMain() int {
|
||||||
TTY, err = tty.Open()
|
TTY, err = tty.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "No tty available: %s\n", err)
|
fmt.Fprintf(os.Stderr, "No tty available: %s\n", err)
|
||||||
|
} else {
|
||||||
|
defer TTY.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui = &packer.BasicUi{
|
ui = &packer.BasicUi{
|
||||||
|
|
|
@ -2,4 +2,5 @@ package packer
|
||||||
|
|
||||||
type TTY interface {
|
type TTY interface {
|
||||||
ReadString() (string, error)
|
ReadString() (string, error)
|
||||||
|
Close() error
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ type testTTY struct {
|
||||||
say string
|
say string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tty *testTTY) Close() error { return nil }
|
||||||
func (tty *testTTY) ReadString() (string, error) {
|
func (tty *testTTY) ReadString() (string, error) {
|
||||||
return tty.say, nil
|
return tty.say, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue