Skip to content

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

Closed

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

Activity

  1. ghost added
    untriaged
    on Jan 23, 2022
  2. stephentoub commented on Jan 24, 2022

    @stephentoub
    Member

    cc: @tmds

  3. tmds commented on Jan 24, 2022

    @tmds
    Member

    @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.

  4. self-assigned this
    on Jan 24, 2022
  5. removed
    untriaged
    on Jan 24, 2022
  6. added this to the 7.0.0 milestone on Jan 24, 2022
  7. ghost added
    in-pr
    on Jan 24, 2022
  8. danielbisar commented on Jan 26, 2022

    @danielbisar
    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.

  9. ghost removed
    in-pr
    on Feb 7, 2022
  10. ghost locked as resolved and limited conversation to collaborators on Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions