Example #1
0
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))
	}
}
Example #2
0
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)})
}
Example #3
0
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()
}