本文整理匯總了Golang中github.com/dotcloud/docker/term.SetWinsize函數的典型用法代碼示例。如果您正苦於以下問題:Golang SetWinsize函數的具體用法?Golang SetWinsize怎麽用?Golang SetWinsize使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了SetWinsize函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Resize
func (host *Host) Resize(h int, w int) {
fmt.Fprintf(log.host, "resizing pty to h=%d w=%d\r\n", h, w)
err := term.SetWinsize(host.pty.Fd(), &term.Winsize{Height: uint16(h), Width: uint16(w)})
if err.(syscall.Errno) != 0 {
panic(fmt.Errorf("siphon: host error setting terminal size: %s\n", err))
}
}
示例2: Resize
func (container *Container) Resize(h, w int) error {
pty, ok := container.ptyMaster.(*os.File)
if !ok {
return fmt.Errorf("ptyMaster does not have Fd() method")
}
return term.SetWinsize(pty.Fd(), &term.Winsize{Height: uint16(h), Width: uint16(w)})
}
示例3: worker
func worker() {
worker := beam.NewWorker(&beam.NetTransport{"tcp", ":6379"}, "/jobs")
worker.RegisterJob("tty", func(name string, args []string, env map[string]string, streams beam.Streamer, db beam.DB) error {
p := exec.Command("bash")
master, slave, err := pty.Open()
if err != nil {
return err
}
if slave == nil {
return fmt.Errorf("tty is nil")
}
term.SetWinsize(master.Fd(), winsize)
p.Stdout = slave
p.Stderr = slave
p.Stdin = slave
p.SysProcAttr = &syscall.SysProcAttr{Setctty: true, Setsid: true}
go streams.ReadFrom(master, "stdout")
go streams.ReadFrom(master, "stderr")
go streams.WriteTo(master, "stdin")
return p.Run()
})
worker.Work()
}