Console.Unix: reset terminal at exit in less cases to avoid blocking the parent....
authorTom Deseyn <tom.deseyn@gmail.com>
Wed, 7 Oct 2020 02:25:43 +0000 (04:25 +0200)
committerGitHub <noreply@github.com>
Wed, 7 Oct 2020 02:25:43 +0000 (22:25 -0400)
commitd6887d4aeec045aa4d708463abdfb6e071660dc8
tree67a52cd8bd560292f34b7c8c4b055c1290eb8881
parentfdc6472bd1de22b3fe67e232ca86d0593d0b7ce7
Console.Unix: reset terminal at exit in less cases to avoid blocking the parent. (#42303)

* Console.Unix: reset terminal at exit in less cases to avoid blocking the parent.

When a parent is fetching the Console.Cursor position, it configures the terminal
to not echo, writes an escape sequence to query the position, and then reads the
position from stdin.

Because this doesn't happen atomically a child process can overwrite the terminal
settings to echo before the parent starts reading. This causes the position to
be echoed to the user, and the parent gets stuck waiting for input on stdin.

Currently terminal settings are reset at exit for applications that use the
Console or Process class. This change tracks whether the application has
changes the terminal settings and only then resets the terminal settings.

This doesn't fix the issue, but makes it less likely to occur.

* TermInfo changes are no longer needed

* Only configure terminal for child if we've touched the settings.

* minor change to comment wording
src/libraries/Native/Unix/System.Native/pal_console.c