Move tty set and restore to caller Upstream-commit: 4a9523adc90de8fea1de23b5e33ae184bdd9f25e Component: engine