Fixed tty terminal handling

Added tty terminal detection so that no tty reconfiguration will be
performed when no tty terminal is attached to the buildgear process.

This was reported to be an issue when deploying builds under Jenkins.