Fix Interactive container hangs when redirecting stdout

Fixes #6509
Closes #7658

This is a rebase of #7658 + tests. Thanks @VojtechVitek !

I even tested the `events` test with one commit before the #5979 PR and it failed. So all 3 are needed.

Ping @erikh @jfrazelle
```
// isTerminal describes if client's STDIN is a TTY
isTerminal    bool
// isTerminalOut describes if client's STDOUT is a TTY
isTerminalOut bool
// terminalFd holds file descriptor of the client's STDIN, in case it is a TTY
terminalFd    uintptr
// terminalFd holds file descriptor of the client's STDOUT, in case it is a TTY
terminalFdOut uintptr
```

^ feel free to make the above simpler