Improve the terminal restoring from RAW format

Use a defer mechanism to restore the terminal from its RAW state. This
way it's resilient to panic calls
pull/25/head
Vasile Popescu 4 years ago committed by Elis Popescu
parent 1646e00a12
commit e1f4cdd06d

@ -146,6 +146,8 @@ Flags:
bufio.NewReader(os.Stdin).ReadString('\n')
ptyMaster := ptyMasterNew()
defer ptyMaster.Restore()
ptyMaster.Start(*commandName, strings.Fields(*commandArgs))
var pty server.PTYHandler = ptyMaster

@ -101,7 +101,10 @@ func (pty *ptyMaster) Refresh() {
func (pty *ptyMaster) Wait() (err error) {
err = pty.command.Wait()
// The terminal has to be restored from the RAW state, to its initial state
return
}
func (pty *ptyMaster) Restore() {
terminal.Restore(0, pty.terminalInitState)
return
}

Loading…
Cancel
Save