Fix race condition when exec with tty Upstream-commit: 790d8f8520d23d16cc0a141e6fd56246a45b327a Component: engine