Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Tracked by #64487
danielbisar opened this issue Jan 23, 2022 · 4 comments · Fixed by #64200
Closed
Tracked by #64487

Comments

@danielbisar
Copy link

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

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Console untriaged New issue has not been triaged by the area owner labels Jan 23, 2022
@ghost
Copy link

ghost commented Jan 23, 2022

Tagging subscribers to this area: @dotnet/area-system-console
See info in area-owners.md if you want to be subscribed.

Issue Details

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

Author: danielbisar
Assignees: -
Labels:

area-System.Console, untriaged

Milestone: -

@stephentoub
Copy link
Member

cc: @tmds

@tmds
Copy link
Member

tmds commented Jan 24, 2022

@danielbisar thank you for the clear reproducer.

It looks like a regression from #54136 which causes SIGINT/SIGQUIT handlers to no longer to be registered unless PosixSignalRegistration or Console.CancelKeyPress are used.

@tmds tmds self-assigned this Jan 24, 2022
@adamsitnik adamsitnik removed the untriaged New issue has not been triaged by the area owner label Jan 24, 2022
@adamsitnik adamsitnik added this to the 7.0.0 milestone Jan 24, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jan 24, 2022
@danielbisar
Copy link
Author

@danielbisar thank you for the clear reproducer.

It looks like a regression from #54136 which causes SIGINT/SIGQUIT handlers to no longer to be registered unless PosixSignalRegistration or Console.CancelKeyPress are used.

Thank you for the fast fix.

@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Feb 7, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Mar 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants