mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-09-30 03:51:43 +02:00
orchard ssh vm: fix "The handle is invalid." error on Windows (#217)
This commit is contained in:
@@ -98,16 +98,17 @@ func runSSHVM(cmd *cobra.Command, args []string) error {
|
||||
// Switch controlling terminal into raw mode,
|
||||
// otherwise ANSI escape sequences that allow
|
||||
// for cursor control and more wouldn't work
|
||||
terminalFd := int(os.Stdin.Fd())
|
||||
state, err := term.MakeRaw(terminalFd)
|
||||
stdinFD := int(os.Stdin.Fd())
|
||||
state, err := term.MakeRaw(stdinFD)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%w: failed to switch controlling terminal into raw mode: %v", ErrFailed, err)
|
||||
}
|
||||
defer func() {
|
||||
_ = term.Restore(terminalFd, state)
|
||||
_ = term.Restore(stdinFD, state)
|
||||
}()
|
||||
|
||||
width, height, err := term.GetSize(terminalFd)
|
||||
stdoutFD := int(os.Stdout.Fd())
|
||||
width, height, err := term.GetSize(int(os.Stdout.Fd()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -131,7 +132,7 @@ func runSSHVM(cmd *cobra.Command, args []string) error {
|
||||
// Periodically adjust remote terminal size
|
||||
go func() {
|
||||
for {
|
||||
newWidth, newHeight, err := term.GetSize(terminalFd)
|
||||
newWidth, newHeight, err := term.GetSize(stdoutFD)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user