simplify loop

This commit is contained in:
Dawid Dziurla 2019-07-08 17:02:16 +02:00
parent c4240e0ff0
commit 5cb1570039
No known key found for this signature in database
GPG key ID: 7B6D8368172E9B0B

View file

@ -394,6 +394,7 @@ func (c *Container) Attach() error {
if c.Details.Config.OpenStdin { if c.Details.Config.OpenStdin {
go func() { go func() {
// the default escape key sequence: ctrl-p, ctrl-q // the default escape key sequence: ctrl-p, ctrl-q
//
// shamelessly taken from docker/cli // shamelessly taken from docker/cli
escapeKeys := []byte{16, 17} escapeKeys := []byte{16, 17}
// Stop reading if escape sequence had been entered // Stop reading if escape sequence had been entered
@ -404,8 +405,7 @@ func (c *Container) Attach() error {
} }
for { for {
select { sig := <-channel
case sig := <-channel:
if sig == syscall.SIGWINCH { if sig == syscall.SIGWINCH {
err := c.Resize(fd) err := c.Resize(fd)
if err != nil { if err != nil {
@ -422,7 +422,6 @@ func (c *Container) Attach() error {
} }
} }
} }
}
func (c *Container) Resize(fd int) error { func (c *Container) Resize(fd int) error {
width, height, err := terminal.GetSize(fd) width, height, err := terminal.GetSize(fd)