Skip to content

Console.ReadLine on Ubuntu in WSL disables echo of characters when cancelled with Ctrl-C #64166

@danielbisar

Description

@danielbisar

Description

After exiting a program with ctrl-c, that was waiting for input via Console.ReadLine leaves the command line in bad state.

Reproduction Steps

mkdir tmp && cd tmp && dotnet new console
echo 'Console.WriteLine("press ctrl-c"); Console.ReadLine();' > Program.cs
dotnet run

Press ctrl-c as the program asks for. Now you are back on the command line. Try to type anything, you will not see the characters typed.

Expected behavior

Terminal behaves normally as if the program was never run.

Actual behavior

You will not see the characters you type. Another thing I recognized that when executing echo x it does not print a newline anymore but overwrites part of the prompt.

Regression?

No response

Known Workarounds

Execute tput reset in bash.

Configuration

dotnet --version
6.0.101

uname -srvpio
Linux 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 x86_64 GNU/Linux

cat /etc/os-release
NAME="Ubuntu"
VERSION="21.04 (Hirsute Hippo)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 21.04"
VERSION_ID="21.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=hirsute
UBUNTU_CODENAME=hirsute

wsl --status
Default Distribution: Ubuntu-CommPrev
Default Version: 2

Windows Subsystem for Linux was last updated on 09.10.2021
WSL automatic updates are on.

Kernel version: 5.10.60.1

And also tested on Ubuntu 20.04 LTS on WSL2

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions