Skip to content

Commit

Permalink
request pseudo tty to prevent errors when invoking interactive shells
Browse files Browse the repository at this point in the history
  • Loading branch information
kovetskiy committed Jun 30, 2020
1 parent a5d9c85 commit 84ef7d2
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import (
"sync"

"github.com/reconquest/hierr-go"
"github.com/reconquest/karma-go"
"github.com/reconquest/lineflushwriter-go"
"github.com/reconquest/prefixwriter-go"
"github.com/reconquest/runcmd"
"golang.org/x/crypto/ssh"
)

type remoteNodesMap map[*distributedLockNode]*remoteExecutionNode
Expand Down Expand Up @@ -48,19 +51,17 @@ func runRemoteExecution(
outputLock = nil
}

var (
status = &struct {
sync.Mutex

Phase string
Total int
Fails int
Success int
}{
Phase: `exec`,
Total: len(lockedNodes.nodes),
}
)
status := &struct {
sync.Mutex

Phase string
Total int
Fails int
Success int
}{
Phase: `exec`,
Total: len(lockedNodes.nodes),
}

setStatus(status)

Expand Down Expand Up @@ -169,6 +170,20 @@ func runRemoteExecutionNode(
) (*remoteExecutionNode, error) {
remoteCommand := node.runner.Command(command[0], command[1:]...)

modes := ssh.TerminalModes{
ssh.ECHO: 0, // disable echoing
ssh.TTY_OP_ISPEED: 14400, // input speed = 14.4kbaud
ssh.TTY_OP_OSPEED: 14400, // output speed = 14.4kbaud
}

err := remoteCommand.(*runcmd.RemoteCmd).GetSession().RequestPty("xterm", 40, 80, modes)
if err != nil {
return nil, karma.Format(
err,
"request for pseudo terminal failed",
)
}

stdoutBackend := io.Writer(os.Stdout)
stderrBackend := io.Writer(os.Stderr)

Expand Down

0 comments on commit 84ef7d2

Please sign in to comment.