Skip to content

Commit

Permalink
Merge pull request #6684 from hashicorp/b-nomad-exec-stdout-tty
Browse files Browse the repository at this point in the history
nomad exec: check stdout for tty as well
  • Loading branch information
Mahmood Ali committed Nov 19, 2019
2 parents 6275132 + 638434a commit 70a73db
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions command/alloc_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ func (l *AllocExecCommand) Run(args []string) int {

flags.BoolVar(&stdinOpt, "i", true, "")

stdinTty := isStdinTty()
flags.BoolVar(&ttyOpt, "t", stdinTty, "")
inferredTty := isTty()
flags.BoolVar(&ttyOpt, "t", inferredTty, "")

if err := flags.Parse(args); err != nil {
return 1
Expand Down Expand Up @@ -292,9 +292,11 @@ func (l *AllocExecCommand) execImpl(client *api.Client, alloc *api.Allocation, t
alloc, task, tty, command, stdin, stdout, stderr, sizeCh, nil)
}

func isStdinTty() bool {
_, isTerminal := term.GetFdInfo(os.Stdin)
return isTerminal
// isTty returns true if both stdin and stdout are a TTY
func isTty() bool {
_, isStdinTerminal := term.GetFdInfo(os.Stdin)
_, isStdoutTerminal := term.GetFdInfo(os.Stdout)
return isStdinTerminal && isStdoutTerminal
}

// setRawTerminal sets the stream terminal in raw mode, so process captures
Expand Down

0 comments on commit 70a73db

Please sign in to comment.