task: fix some bugs in 'dcos task exec' command. (#886)
task: fix some bugs in 'dcos task exec' command. (#886)

* Only set tty into raw mode for `dcos task exec` when interactive.

Previously, the terminal for 'dcos task exec' was set into raw mode
anytime the '--tty' flags was set (even if '--interactive' was not set).
This would cause the CLI to hang when '--interactive' was not set since
control characters are not interpreted by the local tty once it is set
into raw mode (they are sent to STDIN instead). Since we don't actually
stream STDIN to the remote container without '--interactive' , its safe
to leave the tty in default mode and allow the user to '^C' out of it.

This commit addresses this issue.

* Updated attach input path of 'dcos task exec'.

Previously, we would error out no matter what type of exception was
thrown while trying to establish an ATTACH_CONTAINER_INPUT session with
an agent. This would cause us to sometimes drop the output of command we
launched because it happened to complete before we made the
ATTACH_CONTAINER_INPUT call (because the command actually didn't need to
accept input and just ran to completion). We should only error
out if we we are certain that the error occurred while the container was
still running.

This commit adds logic to update this error handling properly.

dcos/dcos-cli,kensipe/dcos-cli,kensipe/dcos-cli,dcos/dcos-cli,mesosphere/dcos-cli,dcos/dcos-cli,mesosphere/dcos-cli,mesosphere/dcos-cli,kensipe/dcos-cli,dcos/dcos-cli,kensipe/dcos-cli,kensipe/dcos-cli,dcos/dcos-cli